#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9, pi = acos(-1.0);
bool eq(long double a, long double b) { return (abs(a - b) < eps); }
namespace std {
bool operator<(const complex<long double> &lhs,
               const complex<long double> &rhs) {
  if (lhs.real() < rhs.real() - eps) return true;
  if (lhs.real() > rhs.real() + eps) return false;
  return lhs.imag() < rhs.imag();
}
}  // namespace std
complex<long double> input_point() {
  long double x, y;
  cin >> x >> y;
  return complex<long double>(x, y);
}
long double dot(complex<long double> a, complex<long double> b) {
  return real(conj(a) * b);
}
long double cross(complex<long double> a, complex<long double> b) {
  return imag(conj(a) * b);
}
class Line {
 public:
  complex<long double> a, b;
  Line() : a(complex<long double>(0, 0)), b(complex<long double>(0, 0)) {}
  Line(complex<long double> a, complex<long double> b) : a(a), b(b) {}
};
class Circle {
 public:
  complex<long double> p;
  long double r;
  Circle() : p(complex<long double>(0, 0)), r(0) {}
  Circle(complex<long double> p, long double r) : p(p), r(r) {}
};
int ccw(complex<long double> a, complex<long double> b,
        complex<long double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > eps) return 1;
  if (cross(b, c) < -eps) return -1;
  if (dot(b, c) < 0) return 2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
bool isis_ll(Line l, Line m) { return !eq(cross(l.b - l.a, m.b - m.a), 0); }
bool isis_ls(Line l, Line s) {
  return isis_ll(l, s) &&
         (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}
bool isis_ss(Line s, Line t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
         ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
bool isis_lp(Line l, complex<long double> p) {
  return (abs(cross(l.b - p, l.a - p)) < eps);
}
bool isis_sp(Line s, complex<long double> p) {
  return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
complex<long double> proj(Line l, complex<long double> p) {
  long double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}
complex<long double> is_ll(Line s, Line t) {
  complex<long double> sv = s.b - s.a, tv = t.b - t.a;
  assert(cross(sv, tv) != 0);
  return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
long double dist_lp(Line l, complex<long double> p) {
  return abs(p - proj(l, p));
}
long double dist_ll(Line l, Line m) {
  return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
long double dist_ls(Line l, Line s) {
  return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
long double dist_sp(Line s, complex<long double> p) {
  complex<long double> r = proj(s, p);
  return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}
long double dist_ss(Line s, Line t) {
  if (isis_ss(s, t)) return 0;
  return min(
      {dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b)});
}
int main() {
  long double n, m, l;
  while (scanf("%Le %Le %Le", &n, &m, &l), n) {
    vector<vector<Line>> star(n, vector<Line>(5));
    for (int i = 0; i < n; i++) {
      long double x, y, a, r;
      cin >> x >> y >> a >> r;
      vector<complex<long double>> s(5);
      for (int j = 0; j < 5; j++) {
        s[j] = complex<long double>(x + r * sin(-a / 180 * pi),
                                    y + r * cos(a / 180 * pi));
        a += 144;
      }
      for (int j = 0; j < 4; j++) {
        star[i][j] = Line(s[j], s[j + 1]);
      }
      star[i][4] = Line(s[4], s[0]);
    }
    vector<vector<long double>> cost(n, vector<long double>(n, (long double)0));
    for (int i = 0; i < n - 1; i++) {
      for (int j = i + 1; j < n; j++) {
        long double ma = (long double)99999999.9999;
        for (int k = 0; k < 5; k++) {
          for (int li = 0; li < 5; li++) {
            ma = min(ma, dist_ss(star[i][k], star[j][li]));
          }
        }
        cost[i][j] = cost[j][i] = ma;
      }
    }
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        for (int k = 0; k < n; ++k) {
          if (cost[j][k] > cost[j][i] + cost[k][i])
            cost[j][k] = cost[j][i] + cost[k][i];
        }
      }
    }
    printf("%10Le", cost[m - 1][l - 1]);
  }
}
