#include <bits/stdc++.h>
using namespace std;
static const double pi = acos(-1.0);
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));
}
double dis_lp(complex<double> a, complex<double> b, complex<double> c) {
  return abs(cross(b - a, c - a)) / abs(b - a);
}
double dis_lsp(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 dis_lp(a, b, c);
}
int is_intersected(complex<double> a1, complex<double> a2, complex<double> b1,
                   complex<double> b2) {
  return (cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < 0) &&
         (cross(b2 - b1, a1 - b1) * cross(b2 - b1, a2 - b1) < 0);
}
complex<double> rotate(complex<double> a, double d) {
  complex<double> r = polar(1.0, d * 2 * pi / 360);
  return a * r;
}
int INF = 10e8;
int n, m, l;
double dis[100][100];
double x[100];
double y[100];
double a[100];
double r[100];
complex<double> star[100][5];
int main() {
  while (1) {
    cin >> n >> m >> l;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dis[i][j] = INF;
      }
    }
    for (int i = 0; i < n; i++) {
      cin >> x[i] >> y[i] >> a[i] >> r[i];
      complex<double> p = complex<double>(x[i], y[i]);
      complex<double> t = complex<double>(0, r[i]);
      for (int j = 0; j < 5; j++) {
        star[i][j] = p + rotate(t, (double)144 * j + a[i]);
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < 5; k++) {
          for (int l = 0; l < 5; l++) {
            if (is_intersected(star[i][k], star[i][(k + 1) % 5], star[j][l],
                               star[j][(l + 1) % 5])) {
              dis[i][j] = 0;
            }
          }
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < 5; k++) {
          for (int l = 0; l < 5; l++) {
            dis[i][j] = min(dis[i][j], dis_lsp(star[i][k], star[i][(k + 1) % 4],
                                               star[j][l]));
          }
        }
      }
    }
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
        }
      }
    }
    cout << fixed << setprecision(7) << dis[m - 1][l - 1] << endl;
  }
}
