#include <bits/stdc++.h>
using namespace std;
const double PI = 4 * atan(1);
vector<vector<complex<double> > > p;
int n, s, g;
double dot(complex<double> a, complex<double> b) { return real(conj(a) * b); }
double cross(complex<double> a, complex<double> b) { return imag(conj(a) * b); }
double distance_ls_p(complex<double> a, complex<double> b, complex<double> c) {
  if (dot(b - a, c - a) <= 0) return abs(c - a);
  if (dot(a - b, c - b) <= 0) return abs(c - b);
  return abs(cross(b - a, c - a)) / abs(b - a);
}
int is_intersected_ls(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);
}
double distance_ls_ls(complex<double> a1, complex<double> a2,
                      complex<double> a3, complex<double> a4) {
  if (is_intersected_ls(a1, a2, a3, a4)) return 0.0;
  double r1 = distance_ls_p(a1, a2, a3), r2 = distance_ls_p(a1, a2, a4),
         r3 = distance_ls_p(a3, a4, a1), r4 = distance_ls_p(a3, a4, a2);
  if (r1 > r2) r1 = r2;
  if (r3 > r4) r3 = r4;
  if (r1 > r3) return r3;
  return r1;
}
double cal(int a, int b) {
  double ret = 10000000.0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = 0; k < 5; k++) {
        for (int l = k + 1; l < 5; l++) {
          double u = distance_ls_ls(p[a][i], p[a][j], p[b][k], p[b][l]);
          if (ret > u) ret = u;
        }
      }
    }
  }
  return ret;
}
int main() {
  while (cin >> n >> s >> g, n || s || g) {
    p.clear();
    p.resize(n);
    for (int i = 0; i < n; i++) {
      double x, y, a, r;
      complex<double> pot;
      cin >> x >> y >> a >> r;
      complex<double> c = complex<double>(x, y);
      for (int j = 0; j < 5; j++) {
        p[i].push_back(c +
                       polar(r, PI * (a + (double)j * 72.0 + 90.0) / 180.0));
      }
    }
    vector<vector<double> > cost(n, vector<double>(n, 10000000.0));
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        double a = cal(i, j);
        cost[i][j] = a;
        cost[j][i] = a;
      }
    }
    priority_queue<pair<double, int>, vector<pair<double, int> >,
                   greater<pair<double, int> > >
        que;
    que.push(pair<double, int>(0, s - 1));
    vector<double> d(n, 10000000.0);
    d[s - 1] = 0;
    while (!que.empty()) {
      pair<double, int> q = que.top();
      int pos = q.second;
      double dist = q.first;
      que.pop();
      if (pos == g - 1) {
        printf("%.8lf\n", dist);
        break;
      }
      if (dist > d[pos]) {
        continue;
      }
      for (int i = 0; i < n; i++) {
        if (cost[pos][i] == 10000000.0) {
          continue;
        }
        if (cost[pos][i] + dist < d[i]) {
          que.push(pair<double, int>(cost[pos][i] + dist, i));
          d[i] = cost[pos][i] + dist;
        }
      }
    }
  }
  return 0;
}
