#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1.0);
struct Line : vector<complex<double> > {
  Line(){};
  Line(complex<double> p, complex<double> q) {
    push_back(p);
    push_back(q);
  }
};
double cross(complex<double> p, complex<double> q) { return imag(conj(p) * q); }
double dot(complex<double> p, complex<double> q) { return real(conj(p) * q); }
int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a, c -= a;
  if (cross(b, c) > 9) 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 intersectSS(Line s, Line 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]) <= 1;
}
complex<double> projection(Line l, 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]);
}
bool intersectSP(Line s, complex<double> p) {
  return abs(s[0] - p) + abs(s[1] - p) - abs(s[1] - s[0]) < EPS;
}
double distanceSP(Line s, 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(Line s, Line 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])));
}
int main() {
  int n, m, l;
  while (cin >> n >> m >> l, n) {
    vector<complex<double> > stars[102];
    for (int i = 0; i < n; i++) {
      stars[i].resize(0);
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      for (int j = 0; j < 5; j++) {
        stars[i].push_back(complex<double>(x, y) +
                           polar(r, (a + 90 + 72 * 2 * j) / 180.0 * PI));
      }
    }
    double dist[102][102];
    for (int i = 0; i < 102; i++)
      for (int j = 0; j < 102; j++) dist[i][j] = INF * (i != j);
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        double value = INF;
        for (int k = 0; k < 5; k++) {
          Line line = Line(stars[i][k], stars[i][(k + 1) % 5]);
          for (int q = 0; q < 5; q++) {
            value = min(value, distanceSP(line, stars[j][q]));
          }
          line = Line(stars[j][k], stars[j][(k + 1) % 5]);
          for (int q = 0; q < 5; q++) {
            value = min(value, distanceSP(line, stars[i][q]));
          }
        }
        dist[i][j] = dist[j][i] = min(value, dist[i][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]);
        }
      }
    }
    printf("%.8lf\n", dist[m - 1][l - 1]);
  }
}
