#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-8, pi = acos(-1.0);
struct L {
  complex<long double> a, b;
};
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);
}
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_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;
}
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);
}
bool isis_sp(L s, complex<long double> p) {
  return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}
long double dist_pp(complex<long double> p, complex<long double> q) {
  return abs(p - q);
}
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);
}
complex<long double> rotate(long double deg, complex<long double> p) {
  long double rad = deg * pi / 180.0;
  return polar((long double)1.0, rad) * p;
}
struct Star {
  L e[5];
};
long double dist_stst(Star s, Star t) {
  long double val = dist_ss(s.e[0], t.e[0]);
  for (L ss : s.e)
    for (L ts : t.e) {
      val = min(val, dist_ss(ss, ts));
    }
  return val;
}
int main() {
  int n, m, l;
  while (cin >> n >> m >> l and n) {
    m--;
    l--;
    vector<Star> stars(n);
    for (Star &s : stars) {
      int x, y, a, r;
      cin >> x >> y >> a >> r;
      complex<long double> center(x, y);
      cout << center << endl;
      for (int i = 0; i < 5; i++) {
        s.e[i].a = s.e[(i + 3) % 5].b =
            center + polar((long double)r, (a + 72 * i) * pi / 180.0);
      }
    }
    vector<vector<long double>> dist(n);
    for (vector<long double> &v : dist) {
      v.reserve(n);
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = dist_stst(stars[i], stars[j]);
      }
    }
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
    cout << fixed << setprecision(30) << dist[m][l] << endl;
  }
}
