#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int x, y, a, r;
  vector<pair<complex<double>, complex<double> > > side;
} STAR;
complex<double> rotate(complex<double> p, int a) {
  double arg = M_PI / 180 * a;
  return p * complex<double>(cos(arg), sin(arg));
}
double dot(complex<double> a, complex<double> b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(complex<double> a, complex<double> b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
int is_orthogonal(complex<double> a1, complex<double> a2, complex<double> b1,
                  complex<double> b2) {
  return (abs((dot(a1 - a2, b1 - b2)) - (0.0)) < (1e-10));
}
int is_parallel(complex<double> a1, complex<double> a2, complex<double> b1,
                complex<double> b2) {
  return (abs((cross(a1 - a2, b1 - b2)) - (0.0)) < (1e-10));
}
int is_point_on_line(complex<double> a, complex<double> b, complex<double> c) {
  return (abs((cross(b - a, c - a)) - (0.0)) < (1e-10));
}
double distance_l_p(complex<double> a, complex<double> b, complex<double> c) {
  return abs(cross(b - a, c - a)) / abs(b - a);
}
double distance_ls_p(complex<double> a, complex<double> b, complex<double> c) {
  if (dot(b - a, c - a) < (1e-10)) return abs(c - a);
  if (dot(a - b, c - b) < (1e-10)) return abs(c - b);
  return abs(cross(b - a, c - a)) / abs(b - a);
}
int is_intersected_ls(complex<double> a1, complex<double> a2,
                      complex<double> b1, complex<double> b2) {
  return (cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < (1e-10)) &&
         (cross(b2 - b1, a1 - b1) * cross(b2 - b1, a2 - b1) < (1e-10));
}
complex<double> intersection_ls(complex<double> a1, complex<double> a2,
                                complex<double> b1, complex<double> b2) {
  complex<double> b = b2 - b1;
  double d1 = abs(cross(b, a1 - b1));
  double d2 = abs(cross(b, a2 - b1));
  double t = d1 / (d1 + d2);
  return a1 + (a2 - a1) * t;
}
int is_intersected_l(complex<double> a1, complex<double> a2, complex<double> b1,
                     complex<double> b2) {
  return !(abs((cross(a1 - a2, b1 - b2)) - (0.0)) < (1e-10));
}
complex<double> intersection_l(complex<double> a1, complex<double> a2,
                               complex<double> b1, complex<double> b2) {
  complex<double> a = a2 - a1;
  complex<double> b = b2 - b1;
  return a1 + a * cross(b, b1 - a1) / cross(b, a);
}
double dist(STAR start, STAR end) {
  double dis = 1000000000;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      dis = min(dis, distance_ls_p(start.side[i].first, start.side[i].second,
                                   end.side[j].first));
      dis = min(dis, distance_ls_p(start.side[i].first, start.side[i].second,
                                   end.side[j].second));
    }
  }
  return dis;
}
int main() {
  int N, M, L;
  while (1) {
    cin >> N >> M >> L;
    if (N == 0) break;
    vector<STAR> stars;
    for (int i = 0; i < N; i++) {
      int x, y, a, r;
      cin >> x >> y >> a >> r;
      vector<pair<complex<double>, complex<double> > > tmp;
      for (int j = 0; j < 5; j++) {
        complex<double> start =
            rotate(complex<double>(0, r), a + 72 * j) + complex<double>(x, y);
        complex<double> end = rotate(complex<double>(0, r), a + 72 * (j + 1)) +
                              complex<double>(x, y);
        tmp.push_back(pair<complex<double>, complex<double> >(start, end));
      }
      STAR star = {x, y, a, r, tmp};
      stars.push_back(star);
    }
    double distance[100][100];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        distance[i][j] = dist(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++) {
          distance[i][j] = min(distance[i][j], distance[i][k] + distance[k][j]);
        }
      }
    }
    cout << setprecision(10) << distance[M - 1][L - 1] << endl;
  }
}
