#include <bits/stdc++.h>
using namespace std;
namespace std {
bool operator<(complex<long double> a, complex<long double> b) {
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
bool operator>(complex<long double> a, complex<long double> b) {
  return (b < a);
}
}  // namespace std
const long double EPS = 1e-10;
const long double PI = acos((long double)(-1));
int sgn(long double a) {
  if (a < -EPS) return -1;
  if (a > EPS) return 1;
  return 0;
}
int sgn(long double a, long double b) { return sgn(b - a); }
bool near(complex<long double> a, complex<long double> b) {
  return !sgn(abs(a - b));
}
long double cross(complex<long double> a, complex<long double> b) {
  return imag(conj(a) * b);
}
long double dot(complex<long double> a, complex<long double> b) {
  return real(conj(a) * b);
}
long double ssqrt(long double d) {
  d = max<long double>(0, d);
  return sqrt(d);
}
long double sacos(long double d) {
  d = max<long double>(-1, d);
  d = min<long double>(1, d);
  return acos(d);
}
long double deg2rad(long double x) { return x / 180 * PI; }
long double radNorP(long double x) {
  return fmod(fmod(x, 2 * PI) + 2 * PI, 2 * PI);
}
int ccw(complex<long double> a, complex<long double> b,
        complex<long double> c) {
  assert(!near(a, b));
  if (near(a, c) || near(b, c)) return 0;
  int s = sgn(cross(b - a, c - a));
  if (s) return s;
  if (dot(b - a, c - a) < 0) return 2;
  if (dot(a - b, c - b) < 0) return -2;
  return 0;
}
struct L {
  complex<long double> x, y;
  L(){};
  L(complex<long double> x, complex<long double> y) : x(x), y(y){};
};
complex<long double> vec(const L &l) { return l.y - l.x; }
long double abs(const L &l) { return abs(vec(l)); }
long double distLP(const L &l, const complex<long double> &p) {
  return abs(cross(l.y - l.x, p - l.x) / abs(l.y - l.x));
}
long double distSP(const L &s, const complex<long double> &p) {
  long double r = min(abs(s.x - p), abs(s.y - p));
  complex<long double> s2 = vec(s) * complex<long double>(0, 1);
  if (ccw(s.x, s.x + s2, p) == 1) return r;
  if (ccw(s.y, s.y + s2, p) == -1) return r;
  return min(r, distLP(s, p));
}
const int MN = 110;
complex<long double> p[MN][5];
long double g[MN][MN];
int main() {
  while (true) {
    int n, m, l;
    cin >> n >> m >> l;
    m--;
    l--;
    if (!n) break;
    for (int i = 0; i < n; i++) {
      long double x, y, a, r;
      cin >> x >> y >> a >> r;
      for (int j = 0; j < 5; j++) {
        long double aa = a + 90 + 72 * j;
        p[i][j] = complex<long double>(x, y) +
                  polar<long double>(r, radNorP(deg2rad(aa)));
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        long double r = 1e9;
        for (int k = 0; k < 5; k++) {
          L u = L(p[i][k], p[i][(k + 2) % 5]);
          for (int l = 0; l < 5; l++) {
            r = min(r, distSP(u, p[j][l]));
          }
        }
        for (int k = 0; k < 5; k++) {
          L u = L(p[j][k], p[j][(k + 2) % 5]);
          for (int l = 0; l < 5; l++) {
            r = min(r, distSP(u, p[i][l]));
          }
        }
        g[i][j] = g[j][i] = r;
      }
    }
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
        }
      }
    }
    printf("%.20Lf\n", g[m][l]);
  }
  return 0;
}
