#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-8, pi = acos(-1.0);
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);
}
namespace std {
bool operator<(const complex<long double> &lhs,
               const complex<long double> &rhs) {
  return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag()
                                  : lhs.real() < rhs.real();
}
}  // namespace std
struct L {
  complex<long double> a, b;
};
struct C {
  complex<long double> p;
  long double 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(L l, L m) { return abs(cross(l.b - l.a, m.b - m.a)) > eps; }
bool isis_ls(L l, L s) {
  long double a = cross(l.b - l.a, s.a - l.a);
  long double b = cross(l.b - l.a, s.b - l.a);
  return (a * b < eps);
}
bool isis_lp(L l, complex<long double> p) {
  return abs(cross(l.b - p, l.a - p)) < eps;
}
bool isis_ss(L s, L 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_sp(L s, complex<long double> p) {
  return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}
complex<long double> proj(L 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> mirror(L l, complex<long double> p) {
  return (long double)2 * proj(l, p) - p;
}
complex<long double> is_ll(L s, L t) {
  complex<long double> sv = s.b - s.a, tv = t.b - t.a;
  return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
long double dist_lp(L l, complex<long double> p) { return abs(p - proj(l, p)); }
long double dist_ll(L l, L m) { return isis_ll(l, m) ? 0 : dist_lp(l, m.a); }
long double dist_ls(L l, L s) {
  if (isis_ls(l, s)) return 0;
  return min(dist_lp(l, s.a), dist_lp(l, s.b));
}
long double dist_sp(L s, complex<long double> p) {
  complex<long double> r = proj(s, p);
  if (isis_sp(s, r)) return abs(r - p);
  return min(abs(s.a - p), abs(s.b - p));
}
long double dist_ss(L s, L t) {
  if (isis_ss(s, t)) return 0;
  long double a = min(dist_sp(s, t.a), dist_sp(t, s.a));
  long double b = min(dist_sp(s, t.b), dist_sp(t, s.b));
  return min(a, b);
}
vector<complex<long double> > is_cc(C c1, C 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;
}
bool isis_vc(vector<C> vc) {
  vector<complex<long double> > crs;
  int n = vc.size();
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (i); (j)++)
      for (complex<long double> p : is_cc(vc[i], vc[j])) crs.push_back(p);
  for (int(i) = 0; (i) < (n); (i)++) crs.push_back(vc[i].p);
  for (complex<long double> p : crs) {
    bool valid = true;
    for (int(i) = 0; (i) < (n); (i)++)
      if (abs(p - vc[i].p) > vc[i].r + eps) valid = false;
    if (valid) return true;
  }
  return false;
}
vector<complex<long double> > is_lc(C c, L 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(C c, L 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<L> tangent_cp(C c, complex<long double> p) {
  vector<L> 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(L{p, p + v1});
  if (l < eps) return ret;
  ret.push_back(L{p, p + v2});
  return ret;
}
vector<L> tangent_cc(C c1, C c2) {
  vector<L> 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<L> 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(L{q1, q1 + v});
    ret.push_back(L{q2, q2 + v});
  }
  return ret;
}
struct star {
  L e[5];
};
int main() {
  int n, m, l;
  while (cin >> n >> m >> l && n) {
    m--;
    l--;
    vector<star> stars(n);
    for (int i = 0; i < n; i++) {
      long double x, y, a, r;
      cin >> x >> y >> a >> r;
      a = a * pi / 180.0;
      complex<long double> center(x, y);
      long double cos72 = cos(72 * pi / 180.0), sin72 = sin(72 * pi / 180.0);
      long double cosa = cos(a), sina = sin(a);
      complex<long double> d(-r * sina, r * cosa);
      complex<long double> points[5];
      for (int j = 0; j < 5; j++) {
        points[j] = center + d;
        d = complex<long double>(d.real() * cos72 - d.imag() * sin72,
                                 d.real() * sin72 + d.imag() * cos72);
      }
      for (int j = 0; j < 5; j++) {
        stars[i].e[j] = L({points[j % 5], points[(j + 1) % 5]});
      }
    }
    long double wf[101][101];
    const long double INF = 1e20;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        wf[i][j] = (i == j ? 0 : INF);
      }
    }
    for (int i = 0; i < n - 1; i++)
      for (int j = i + 1; j < n; j++) {
        star s1 = stars[i], s2 = stars[j];
        long double dist = INF;
        for (int p = 0; p < 5; p++)
          for (int q = 0; q < 5; q++) {
            dist = min(dist, dist_ss(s1.e[p], s2.e[q]));
          }
        wf[i][j] = wf[j][i] = dist;
      }
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);
        }
      }
    }
    cout << fixed << setprecision(20) << wf[m][l] << endl;
  }
  return 0;
}
