#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double EPS = 1e-9;
const double PI = acos(-1.0);
using star = vector<complex<double>>;
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 ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > EPS) return +1;
  if (cross(b, c) < -EPS) return -1;
  if (dot(b, c) < -EPS) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
bool isecSS(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;
}
bool isecSP(complex<double> a1, complex<double> a2, complex<double> b) {
  return !ccw(a1, a2, b);
}
complex<double> proj(complex<double> a1, complex<double> a2,
                     complex<double> p) {
  return a1 + dot(a2 - a1, p - a1) / norm(a2 - a1) * (a2 - a1);
}
double distSP(complex<double> a1, complex<double> a2, complex<double> p) {
  complex<double> r = proj(a1, a2, p);
  if (isecSP(a1, a2, r)) return abs(r - p);
  return min(abs(a1 - p), abs(a2 - p));
}
double distSS(complex<double> a1, complex<double> a2, complex<double> b1,
              complex<double> b2) {
  if (isecSS(a1, a2, b1, b2)) return 0;
  return min({distSP(a1, a2, b1), distSP(a1, a2, b2), distSP(b1, b2, a1),
              distSP(b1, b2, a2)});
}
star make_star(double x, double y, double a, double r) {
  star s(5);
  for (int i = 0; i < int(5); ++i) {
    s[i] = complex<double>(x, y) + polar(r, (90 + a + 144 * i) * PI / 180.0);
  }
  return s;
}
double dist_star(star s1, star s2) {
  double res = 1e9;
  for (int i = 0; i < int(5); ++i)
    for (int j = 0; j < int(5); ++j) {
      double dist = distSS(s1[i], s1[(i + 1) % 5], s2[i], s2[(i + 1) % 5]);
      res = min(res, dist);
    }
  return res;
}
int main() {
  int N, M, L;
  while (cin >> N >> M >> L, N | M | L) {
    vector<star> st(N);
    for (int i = 0; i < int(N); ++i) {
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      st[i] = make_star(x, y, a, r);
    }
    vector<vector<double>> d(N, vector<double>(N, 1e9));
    for (int i = 0; i < int(N); ++i) d[i][i] = 0;
    for (int i = 0; i < int(N); ++i)
      for (int j = 0; j < int(i); ++j) {
        double dist = dist_star(st[i], st[j]);
        d[i][j] = dist;
        d[j][i] = dist;
      }
    for (int k = 0; k < int(N); ++k)
      for (int i = 0; i < int(N); ++i)
        for (int j = 0; j < int(N); ++j)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    printf("%.20f\n", d[M - 1][L - 1]);
  }
}
