#include <bits/stdc++.h>
using namespace std;
bool operator<(const complex<double>& a, const complex<double>& b) {
  return abs(a) < abs(b);
}
int N, M, L;
double dot(complex<double> a, complex<double> b) { return real(conj(a) * b); }
double cross(complex<double> a, complex<double> b) { return imag(conj(a) * b); }
int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > DBL_EPSILON) return 1;
  if (cross(b, c) < -DBL_EPSILON) return -1;
  if (dot(b, c) < -DBL_EPSILON) return 2;
  if (norm(b) < norm(c) - DBL_EPSILON) return 2;
  return 0;
}
bool isIntersectSS(complex<double> a1, complex<double> a2, complex<double> b1,
                   complex<double> b2) {
  return ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0 &&
         ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0;
}
double DistanceSP(complex<double> a, complex<double> b, complex<double> c) {
  if (dot(b - a, c - a) < DBL_EPSILON) return abs(c - a);
  if (dot(a - b, c - b) < DBL_EPSILON) return abs(c - b);
  return abs(cross(b - a, c - a));
}
double DistaiceSS(complex<double> a, complex<double> b, complex<double> c,
                  complex<double> d) {
  if (isIntersectSS(a, b, c, d)) {
    return 0.0;
  }
  return min(min(DistanceSP(a, b, c), DistanceSP(a, b, d)),
             min(DistanceSP(c, d, a), DistanceSP(c, d, b)));
}
vector<vector<double> > links;
struct Star {
  complex<double> p;
  int a;
  int r;
  Star(complex<double> p, int a, int r) : p(p), a(a), r(r) {}
};
vector<complex<double> > getPoint(Star p) {
  vector<complex<double> > l;
  for (int i = 0; i < 5; i++) {
    double theta = M_PI / 2 + 2 * i * M_PI / 5 + p.a * M_PI / 180;
    l.push_back(complex<double>(p.p.real() + p.r * cos(theta),
                                p.p.imag() + p.r * sin(theta)));
  }
  return l;
}
double getLength(Star p1, Star p2) {
  vector<complex<double> > a = getPoint(p1);
  vector<complex<double> > b = getPoint(p2);
  double m = DBL_MAX;
  for (__typeof((a).begin()) a1 = (a).begin(); a1 != (a).end(); ++a1)
    for (__typeof((a).begin()) a2 = (a).begin(); a2 != (a).end(); ++a2)
      for (__typeof((b).begin()) b1 = (b).begin(); b1 != (b).end(); ++b1)
        for (__typeof((b).begin()) b2 = (b).begin(); b2 != (b).end(); ++b2) {
          m = min(m, DistaiceSS(*a1, *a2, *b1, *b2));
        }
  return m;
}
int x, y, a, r;
int main() {
  while (true) {
    cin >> N >> M >> L;
    if (N == 0 && M == 0 && L == 0) {
      break;
    }
    links.clear();
    vector<Star> stars;
    for (int i = 0; i < N; i++) {
      cin >> x >> y >> a >> r;
      stars.push_back(Star(complex<double>(x, y), a, r));
    }
    for (int i = 0; i < N; i++) {
      vector<double> ld;
      for (int j = 0; j < N; j++) {
        ld.push_back(getLength(stars[i], stars[j]));
      }
      links.push_back(ld);
    }
    for (int k = 0; k < N; k++)
      for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
          links[i][j] = min(links[i][j], links[i][k] + links[k][j]);
    cout << links[M - 1][L - 1] << endl;
  }
}
