#include <bits/stdc++.h>
using namespace std;
const double INF = 1e40;
const double EPS = 1e-8;
const double PI = acos(-1);
enum CCW { FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16 };
int sig(double r) { return (r < -EPS) ? -1 : (r > EPS) ? 1 : 0; }
bool eq(double a, double b) { return abs(a - b) < EPS; }
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 ccw(const complex<double> a, complex<double> b, complex<double> x) {
  b -= a;
  x -= a;
  double cr = cross(b, x);
  if (eq(cr, 0)) {
    if (dot(b, x) < 0) return BACK;
    if (abs(b) < abs(x)) return FRONT;
    return ON;
  }
  return (cr > 0) ? LEFT : RIGHT;
}
complex<double> vec(pair<complex<double>, complex<double> > a) {
  return a.second - a.first;
}
bool iSS(pair<complex<double>, complex<double> > a,
         pair<complex<double>, complex<double> > b) {
  int cwaf = ccw(a.first, a.second, b.first);
  int cwbf = ccw(b.first, b.second, a.first);
  int cwas = ccw(a.first, a.second, b.second);
  int cwbs = ccw(b.first, b.second, a.second);
  if (cwaf == ON || cwas == ON || cwbf == ON || cwbs == ON) return true;
  return (cwaf | cwas) == (LEFT | RIGHT) && (cwbf | cwbs) == (LEFT | RIGHT);
}
double dLP(pair<complex<double>, complex<double> > l, complex<double> x) {
  return abs(cross(vec(l), x - l.first)) / abs(vec(l));
}
double dSP(pair<complex<double>, complex<double> > s, complex<double> x) {
  if (dot(vec(s), x - s.first) <= 0) return abs(x - s.first);
  if (dot(-vec(s), x - s.second) <= 0) return abs(x - s.second);
  return dLP(s, x);
}
double dSS(pair<complex<double>, complex<double> > a,
           pair<complex<double>, complex<double> > b) {
  return iSS(a, b) ? 0
                   : min(min(dSP(a, b.first), dSP(a, b.second)),
                         min(dSP(b, a.first), dSP(b, a.second)));
}
double x[111], y[111], a[111], r[111];
pair<complex<double>, complex<double> > star[111][5];
double dis[111][111];
double mem[111];
void f(int s, int t) {
  double res = 1e40;
  for (int i = 0; i < int(5); ++i)
    for (int j = 0; j < int(5); ++j) {
      res = min(dSS(star[s][i], star[t][j]), res);
    }
  dis[s][t] = res;
}
int main() {
  int n, m, l;
  for (;;) {
    cin >> n >> m >> l;
    if (n == 0 && m == 0 && l == 0) break;
    --m;
    --l;
    for (int i = 0; i < int(n); ++i) cin >> x[i] >> y[i] >> a[i] >> r[i];
    for (int i = 0; i < int(n); ++i) a[i] = a[i] / 360 * 2 * PI;
    for (int i = 0; i < int(n); ++i)
      for (int j = 0; j < int(5); ++j) {
        double theta = a[i] + j * 2 * PI / 5 + PI / 2;
        complex<double> p1 =
            complex<double>(x[i] + r[i] * cos(theta), y[i] + r[i] * sin(theta));
        theta = a[i] + (j + 2) * 2 * PI / 5 + PI / 2;
        complex<double> p2 =
            complex<double>(x[i] + r[i] * cos(theta), y[i] + r[i] * sin(theta));
        star[i][j] = pair<complex<double>, complex<double> >(p1, p2);
      }
    for (int i = 0; i < int(n); ++i)
      for (int j = 0; j < int(n); ++j) f(i, j);
    for (int i = 0; i < int(n); ++i) mem[i] = INF;
    priority_queue<pair<double, int> > que;
    que.push(make_pair(0, m));
    while (!que.empty()) {
      pair<double, int> now = que.top();
      que.pop();
      if (mem[now.second] <= now.first) continue;
      mem[now.second] = now.first;
      for (int i = 0; i < int(n); ++i)
        if (i != now.second) {
          que.push(make_pair(now.first + dis[now.second][i], i));
        }
    }
    printf("%.12lf\n", mem[l]);
  }
}
