#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
double cross(const complex<double> &a, const complex<double> &b) {
  return imag(conj(a) * b);
}
double dot(const complex<double> &a, const complex<double> &b) {
  return real(conj(a) * b);
}
struct L : public vector<complex<double> > {
  L() {}
  L(const complex<double> &a, const complex<double> &b) {
    push_back(a);
    push_back(b);
  }
};
int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0) return +1;
  if (cross(b, c) < 0) return -1;
  if (dot(b, c) < 0) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
bool intersectSP(const L &s, const complex<double> &p) {
  return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
         ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}
complex<double> projection(const L &l, const complex<double> &p) {
  double t = dot(p - l[0], l[0] - l[1]) / norm(l[0] - l[1]);
  return l[0] + t * (l[0] - l[1]);
}
double distanceSP(const L &s, const complex<double> &p) {
  const complex<double> r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s[0] - p), abs(s[1] - p));
}
double distanceSS(const L &s, const L &t) {
  if (intersectSS(s, t)) return 0;
  return min(min(distanceSP(s, t[0]), distanceSP(s, t[1])),
             min(distanceSP(t, s[0]), distanceSP(t, s[1])));
}
const double PI = 3.14159265358979323846264;
double deg2rad(double deg) { return deg * PI / 180; }
complex<double> rotate(complex<double> p, complex<double> c, double d) {
  return c + (p - c) * complex<double>(cos(d), sin(d));
}
const int INF = 1000000000;
L star[200][5];
double d[200][200];
double diststar(int i, int j) {
  double ans = 1000000;
  for (int ii = 0; ii < 5; ii++)
    for (int ji = 0; ji < 5; ji++)
      ans = min(ans, distanceSS(star[i][ii], star[j][ji]));
  return ans;
}
int main() {
  int n, m, l;
  while (scanf("%d %d %d", &n, &m, &l), n) {
    for (int i = 0; i < n; i++) {
      double x, y, a, r;
      scanf("%lf %lf %lf %lf", &x, &y, &a, &r);
      complex<double> c(x, y), up(x, y + r);
      for (int j = 0; j < 5; j++) {
        complex<double> f =
            c + r * rotate(complex<double>(0, 1), complex<double>(0, 0),
                           deg2rad(j * 72 + a));
        complex<double> t =
            c + r * rotate(complex<double>(0, 1), complex<double>(0, 0),
                           deg2rad(((j + 1) % 5) * 72 + a));
        star[i][j] = L(f, t);
      }
    }
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) d[i][j] = (i == j ? 0 : diststar(i, j));
    for (int k = 0; k < n; k++)
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    printf("%.15f\n", d[m - 1][l - 1]);
  }
}
