#include <bits/stdc++.h>
using namespace std;
using ld = long double;
const long double eps = 1e-9, pi = acos(-1.0);
bool eq(long double a, long double b) { return (abs(a - b) < eps); }
namespace std {
bool operator<(const complex<long double> &lhs,
               const complex<long double> &rhs) {
  if (lhs.real() < rhs.real() - eps) return true;
  if (lhs.real() > rhs.real() + eps) return false;
  return lhs.imag() < rhs.imag();
}
}  // namespace std
complex<long double> input_point() {
  long double x, y;
  cin >> x >> y;
  return complex<long double>(x, y);
}
long double dot(complex<long double> a, complex<long double> b) {
  return real(conj(a) * b);
}
long double cross(complex<long double> a, complex<long double> b) {
  return imag(conj(a) * b);
}
class Line {
 public:
  complex<long double> a, b;
  Line() : a(complex<long double>(0, 0)), b(complex<long double>(0, 0)) {}
  Line(complex<long double> a, complex<long double> b) : a(a), b(b) {}
};
class Circle {
 public:
  complex<long double> p;
  long double r;
  Circle() : p(complex<long double>(0, 0)), r(0) {}
  Circle(complex<long double> p, long double r) : p(p), r(r) {}
};
int ccw(complex<long double> a, complex<long double> b,
        complex<long double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > eps) return 1;
  if (cross(b, c) < -eps) return -1;
  if (dot(b, c) < 0) return 2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
bool isis_ll(Line l, Line m) { return !eq(cross(l.b - l.a, m.b - m.a), 0); }
bool isis_ls(Line l, Line s) {
  return isis_ll(l, s) &&
         (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}
bool isis_ss(Line s, Line t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
         ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
bool isis_lp(Line l, complex<long double> p) {
  return (abs(cross(l.b - p, l.a - p)) < eps);
}
bool isis_sp(Line s, complex<long double> p) {
  return (abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps);
}
complex<long double> proj(Line l, complex<long double> p) {
  long double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}
complex<long double> is_ll(Line s, Line t) {
  complex<long double> sv = s.b - s.a, tv = t.b - t.a;
  assert(cross(sv, tv) != 0);
  return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}
long double dist_lp(Line l, complex<long double> p) {
  return abs(p - proj(l, p));
}
long double dist_ll(Line l, Line m) {
  return isis_ll(l, m) ? 0 : dist_lp(l, m.a);
}
long double dist_ls(Line l, Line s) {
  return isis_ls(l, s) ? 0 : min(dist_lp(l, s.a), dist_lp(l, s.b));
}
long double dist_sp(Line s, complex<long double> p) {
  complex<long double> r = proj(s, p);
  return isis_sp(s, r) ? abs(r - p) : min(abs(s.a - p), abs(s.b - p));
}
long double dist_ss(Line s, Line t) {
  if (isis_ss(s, t)) return 0;
  return min(
      {dist_sp(s, t.a), dist_sp(s, t.b), dist_sp(t, s.a), dist_sp(t, s.b)});
}
int main() {
  int N, M, L;
  const long double phi2 = (3 + sqrtl(5)) / 2;
  cout << fixed << setprecision(15);
  while (cin >> N >> M >> L, N || M || L) {
    vector<vector<long double>> dis(N, vector<long double>(N, 10000000000));
    for (int i = 0; i < N; i++) {
      dis[i][i] = 0;
    }
    vector<vector<complex<long double>>> seg(N,
                                             vector<complex<long double>>(10));
    vector<long double> x(N), y(N), a(N), r(N);
    for (int i = 0; i < N; i++) {
      cin >> x[i] >> y[i] >> a[i] >> r[i];
      for (int j = 0; j < 10; j++) {
        seg[i][j] =
            complex<long double>(x[i], y[i]) +
            complex<long double>(cosl((90 + a[i] + 36 * j) / 180.0 * pi),
                                 sinl((90 + a[i] + 36 * j) / 180 * pi)) *
                (j & 1 ? r[i] / phi2 : r[i]);
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        for (int ii = 0; ii < 10; ii++) {
          for (int jj = 0; jj < 10; jj++) {
            dis[i][j] = min(dis[i][j],
                            dist_ss(Line(seg[i][ii], seg[i][(ii + 1) % 10]),
                                    Line(seg[j][jj], seg[j][(jj + 1) % 10])));
          }
        }
      }
    }
    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 << dis[M - 1][L - 1] << endl;
  }
  return 0;
}
