#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9, pi = acos(-1.0);
const int INF = numeric_limits<int>::max() / 2;
const double PI = 3.14159265358979323846;
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)});
}
vector<complex<long double> > is_cc(Circle c1, Circle c2) {
  vector<complex<long double> > res;
  long double d = abs(c1.p - c2.p);
  long double rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
  long double dfr = c1.r * c1.r - rc * rc;
  if (abs(dfr) < eps)
    dfr = 0.0;
  else if (dfr < 0.0)
    return res;
  long double rs = sqrt(dfr);
  complex<long double> diff = (c2.p - c1.p) / d;
  res.push_back(c1.p + diff * complex<long double>(rc, rs));
  if (dfr != 0.0) res.push_back(c1.p + diff * complex<long double>(rc, -rs));
  return res;
}
vector<complex<long double> > is_lc(Circle c, Line l) {
  vector<complex<long double> > res;
  long double d = dist_lp(l, c.p);
  if (d < c.r + eps) {
    long double len = (d > c.r) ? 0.0 : sqrt(c.r * c.r - d * d);
    complex<long double> nor = (l.a - l.b) / abs(l.a - l.b);
    res.push_back(proj(l, c.p) + len * nor);
    res.push_back(proj(l, c.p) - len * nor);
  }
  return res;
}
vector<complex<long double> > is_sc(Circle c, Line l) {
  vector<complex<long double> > v = is_lc(c, l), res;
  for (complex<long double> p : v)
    if (isis_sp(l, p)) res.push_back(p);
  return res;
}
vector<Line> tangent_cp(Circle c, complex<long double> p) {
  vector<Line> ret;
  complex<long double> v = c.p - p;
  long double d = abs(v);
  long double l = sqrt(norm(v) - c.r * c.r);
  if (isnan(l)) {
    return ret;
  }
  complex<long double> v1 = v * complex<long double>(l / d, c.r / d);
  complex<long double> v2 = v * complex<long double>(l / d, -c.r / d);
  ret.push_back(Line(p, p + v1));
  if (l < eps) return ret;
  ret.push_back(Line(p, p + v2));
  return ret;
}
vector<Line> tangent_cc(Circle c1, Circle c2) {
  vector<Line> ret;
  if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
    complex<long double> center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
    ret = tangent_cp(c1, center);
  }
  if (abs(c1.r - c2.r) > eps) {
    complex<long double> out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
    vector<Line> nret = tangent_cp(c1, out);
    ret.insert(ret.end(), (nret).begin(), (nret).end());
  } else {
    complex<long double> v = c2.p - c1.p;
    v /= abs(v);
    complex<long double> q1 = c1.p + v * complex<long double>(0, 1) * c1.r;
    complex<long double> q2 = c1.p + v * complex<long double>(0, -1) * c1.r;
    ret.push_back(Line(q1, q1 + v));
    ret.push_back(Line(q2, q2 + v));
  }
  return ret;
}
long double area(const vector<complex<long double> > &p) {
  long double res = 0;
  int n = p.size();
  for (int j = 0; j < (int)(n); j++) res += cross(p[j], p[(j + 1) % n]);
  return res / 2;
}
bool is_counter_clockwise(const vector<complex<long double> > &poly) {
  long double angle = 0;
  int n = poly.size();
  for (int i = 0; i < (int)(n); i++) {
    complex<long double> a = poly[i], b = poly[(i + 1) % n],
                         c = poly[(i + 2) % n];
    angle += arg((c - b) / (b - a));
  }
  return angle > eps;
}
int is_in_polygon(const vector<complex<long double> > &poly,
                  complex<long double> p) {
  long double angle = 0;
  int n = poly.size();
  for (int i = 0; i < (int)(n); i++) {
    complex<long double> a = poly[i], b = poly[(i + 1) % n];
    if (isis_sp(Line(a, b), p)) return 1;
    angle += arg((b - p) / (a - p));
  }
  return eq(angle, 0) ? 0 : 2;
}
vector<complex<long double> > convex_hull(vector<complex<long double> > ps) {
  int n = ps.size();
  int k = 0;
  sort(ps.begin(), ps.end());
  vector<complex<long double> > ch(2 * n);
  for (int i = 0; i < n; ch[k++] = ps[i++])
    while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
  for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
    while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
  ch.resize(k - 1);
  return ch;
}
vector<complex<long double> > convex_cut(
    const vector<complex<long double> > &ps, Line l) {
  int n = ps.size();
  vector<complex<long double> > Q;
  for (int i = 0; i < (int)(n); i++) {
    complex<long double> A = ps[i], B = ps[(i + 1) % n];
    Line m = Line(A, B);
    if (ccw(l.a, l.b, A) != -1) Q.push_back(A);
    if (ccw(l.a, l.b, A) * ccw(l.a, l.b, B) < 0 && isis_ll(l, m))
      Q.push_back(is_ll(l, m));
  }
  return Q;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (true) {
    int n, m, l;
    cin >> n >> m >> l;
    if (n == 0) break;
    vector<complex<long double> > stars[n];
    for (int i = 0; i < n; i++) {
      int x, y, a, r;
      cin >> x >> y >> a >> r;
      for (int j = 0; j < 5; j++) {
        complex<long double> v =
            complex<long double>(x, y) +
            complex<long double>(r * cos((18 + a + 72 * j) * (2 * PI) / 360),
                                 r * sin((18 + a + 72 * j) * (2 * PI) / 360));
        stars[i].push_back(v);
      }
    }
    long double dis[n][n];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        if (i == j)
          dis[i][j] = 0.0;
        else
          dis[i][j] = INF;
      }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        long double tmp = INF;
        for (int k = 0; k < 5; k++) {
          for (int l = 0; l < 5; l++) {
            Line x = Line(stars[i][k], stars[i][(k + 2) % 5]);
            Line y = Line(stars[j][l], stars[j][(l + 2) % 5]);
            tmp = min(tmp, dist_ss(x, y));
          }
        }
        dis[i][j] = tmp;
        dis[j][i] = tmp;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < n; k++) {
          dis[i][k] = min(dis[i][k], dis[i][j] + dis[j][k]);
        }
      }
    }
    cout << setprecision(10) << dis[m - 1][l - 1] << endl;
  }
}
