#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chadd(T &a, T b) {
  a = a + b;
}
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
constexpr long long INF = 1001001001001001LL;
constexpr long long MOD = 1000000007LL;
double deg2rad(double x) { return x * M_PI / 180.0; }
complex<double> rotatePoint(complex<double> a, complex<double> b, double z) {
  z = deg2rad(z);
  b -= a;
  double rx = b.real() * cos(z) - b.imag() * sin(z);
  double ry = b.real() * sin(z) + b.imag() * cos(z);
  complex<double> ret(rx, ry);
  ret += a;
  return ret;
}
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());
}
long long int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > (1e-10)) return +1;
  if (cross(b, c) < -(1e-10)) return -1;
  if (dot(b, c) < 0) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
double dist_sp(complex<double> a1, complex<double> a2, complex<double> b) {
  if (dot(a2 - a1, b - a1) < (1e-10)) return abs(b - a1);
  if (dot(a1 - a2, b - a2) < (1e-10)) return abs(b - a2);
  return abs(cross(a2 - a1, b - a1)) / abs(a2 - a1);
}
bool isec_ss(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 dist_ss(complex<double> a1, complex<double> a2, complex<double> b1,
               complex<double> b2) {
  if (isec_ss(a1, a2, b1, b2)) return 0;
  return min(min(dist_sp(a1, a2, b1), dist_sp(a1, a2, b2)),
             min(dist_sp(b1, b2, a1), dist_sp(b1, b2, a2)));
}
long long int N, M, LS;
double dist[110][110];
signed main() {
  while (cin >> N >> M >> LS, N || M || LS) {
    M--;
    LS--;
    double x, y, a, r;
    vector<complex<double> > ps[110];
    vector<pair<complex<double>, complex<double> > > ls[110];
    for (long long int(i) = (0); (i) < (N); (i)++) {
      cin >> x >> y >> a >> r;
      complex<double> po = complex<double>(x, y),
                      pt = complex<double>(x, y + r);
      pt = rotatePoint(po, pt, a);
      for (long long int(j) = (0); (j) < (5); (j)++) {
        double deg = 72.0 * j;
        ps[i].push_back(rotatePoint(po, pt, deg));
      }
      ls[i].push_back(
          pair<complex<double>, complex<double> >(ps[i][0], ps[i][2]));
      ls[i].push_back(
          pair<complex<double>, complex<double> >(ps[i][0], ps[i][3]));
      ls[i].push_back(
          pair<complex<double>, complex<double> >(ps[i][1], ps[i][3]));
      ls[i].push_back(
          pair<complex<double>, complex<double> >(ps[i][1], ps[i][4]));
      ls[i].push_back(
          pair<complex<double>, complex<double> >(ps[i][2], ps[i][4]));
    }
    for (long long int(i) = (0); (i) < (N); (i)++)
      for (long long int(j) = (0); (j) < (N); (j)++) {
        dist[i][j] = INF;
        for (long long int(x) = (0); (x) < (5); (x)++)
          for (long long int(y) = (0); (y) < (5); (y)++) {
            double temp = dist_ss(ls[i][x].first, ls[i][x].second,
                                  ls[j][y].first, ls[j][y].second);
            chmin(dist[i][j], temp);
          }
      }
    for (long long int(k) = (0); (k) < (N); (k)++)
      for (long long int(i) = (0); (i) < (N); (i)++)
        for (long long int(j) = (0); (j) < (N); (j)++) {
          chmin(dist[i][j], dist[i][k] + dist[k][j]);
        }
    printf("%.12f\n", dist[M][LS]);
  }
  return 0;
}
