#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
double PI;
typedef struct {
  complex<double> c[5];
} star;
star stars[100];
double dist[100][100];
inline double dot(complex<double> p1, complex<double> p2) {
  return real(p1 * conj(p2));
}
inline double cross(complex<double> p1, complex<double> p2) {
  return imag(p1 * conj(p2));
}
inline double getcos(complex<double> p1, complex<double> p0,
                     complex<double> p2) {
  complex<double> v1 = p1 - p0;
  complex<double> v2 = conj(p2 - p0);
  return dot(v1, v2) / sqrt(norm(v1) * norm(v2));
}
int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0) return +1;
  if (cross(b, c) < 0) return -1;
  if (dot(b, c) < 0) return +2;
  if (norm(b) < norm(c)) return -2;
}
bool intersectSS(const complex<double> &L1a, const complex<double> &L1b,
                 const complex<double> &L2a, const complex<double> &L2b) {
  return ccw(L1a, L1b, L2a) * ccw(L1a, L1b, L2b) <= 0 &&
         ccw(L2a, L2b, L1a) * ccw(L2a, L2b, L1b) <= 0;
}
inline double distPP(complex<double> p1, complex<double> p2) {
  return sqrt(norm(p1 - p2));
}
inline double distPL(complex<double> p, complex<double> L1,
                     complex<double> L2) {
  double a, b, c;
  a = L2.imag() - L1.imag();
  b = -(L2.real() - L1.real());
  c = L2.real() * L1.imag() - L1.real() * L2.imag();
  return abs(a * p.real() + b * p.imag() + c) / sqrt(pow(a, 2.0) + pow(b, 2.0));
}
inline double distLL(complex<double> a1, complex<double> a2, complex<double> b1,
                     complex<double> b2) {
  double ret = 1e15;
  double cos1, cos2;
  if (intersectSS(a1, a2, b1, b2)) return 0.0;
  cos1 = getcos(b1, b2, a1);
  cos2 = getcos(b2, b1, a1);
  if (cos1 > 0 && cos2 > 0)
    ret = min(ret, distPL(a1, b1, b2));
  else
    ret = min(ret, min(distPP(a1, b1), distPP(a1, b2)));
  cos1 = getcos(b1, b2, a2);
  cos2 = getcos(b2, b1, a2);
  if (cos1 > 0 && cos2 > 0)
    ret = min(ret, distPL(a2, b1, b2));
  else
    ret = min(ret, min(distPP(a2, b1), distPP(a2, b2)));
  cos1 = getcos(a1, a2, b1);
  cos2 = getcos(a2, a1, b1);
  if (cos1 > 0 && cos2 > 0)
    ret = min(ret, distPL(b1, a1, a2));
  else
    ret = min(ret, min(distPP(b1, a1), distPP(b1, a2)));
  cos1 = getcos(a1, a2, b2);
  cos2 = getcos(a2, a1, b2);
  if (cos1 > 0 && cos2 > 0)
    ret = min(ret, distPL(b2, a1, a2));
  else
    ret = min(ret, min(distPP(b2, a1), distPP(b2, a2)));
  return ret;
}
double distSS(int p, int q) {
  if (p == q) return 0;
  double ret = 1e15;
  for (int i = (0); i < (5); ++i) {
    for (int j = (0); j < (5); ++j) {
      ret = min(ret, distLL(stars[p].c[i], stars[p].c[(i + 2) % 5],
                            stars[q].c[j], stars[q].c[(j + 2) % 5]));
    }
  }
  return ret;
}
int main() {
  PI = acos(-1.0);
  while (1) {
    int n, m, l;
    cin >> n >> m >> l;
    if (n == 0) return 0;
    m--, l--;
    for (int i = (0); i < (n); ++i) {
      double x, y, a, r;
      scanf("%lf%lf%lf%lf", &x, &y, &a, &r);
      for (int j = (0); j < (5); ++j)
        stars[i].c[j] =
            complex<double>(x - r * sin((a + 72.0 * j) / 180.0 * PI),
                            y + r * cos((a + 72.0 * j) / 180.0 * PI));
    }
    for (int i = (0); i < (n); ++i) {
      dist[i][i] = 0.0;
      for (int j = (0); j < (i); ++j) {
        dist[i][j] = dist[j][i] = distSS(i, j);
      }
    }
    for (int k = (0); k < (n); ++k) {
      for (int i = (0); i < (n); ++i) {
        for (int j = (0); j < (i); ++j) {
          dist[j][i] = dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }
    printf("%.15f\n", dist[m][l]);
  }
}
