#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
double dot_prod(complex<double> a, complex<double> b) {
  return a.real() * b.real() + a.imag() * b.imag();
}
double cross_prod(complex<double> a, complex<double> b) {
  return a.real() * b.imag() - a.imag() * b.real();
}
double dist_pts_line(complex<double> p,
                     pair<complex<double>, complex<double> > l) {
  complex<double> a, b;
  a = l.first - p;
  b = l.second - p;
  return abs(cross_prod(a, b) / abs(l.first - l.second));
}
bool has_intersec_seg_seg(pair<complex<double>, complex<double> > a,
                          pair<complex<double>, complex<double> > b) {
  complex<double> va, vb, vc;
  bool res = true;
  for (int i = 0; i < 2; i++) {
    va = b.first - a.first;
    vb = b.second - a.first;
    vc = a.second - a.first;
    res = res && cross_prod(va, vc) * cross_prod(vb, vc) < EPS;
    swap(a, b);
  }
  res = res && abs(cross_prod(a.first - a.second, b.first - b.second)) > EPS;
  return res;
}
double dist_pts_seg(complex<double> p,
                    pair<complex<double>, complex<double> > a) {
  double res;
  res = min(abs(a.first - p), abs(a.second - p));
  if (dot_prod(a.second - a.first, p - a.first) > -EPS &&
      dot_prod(a.first - a.second, p - a.second) > -EPS)
    res = min(res, dist_pts_line(p, a));
  return res;
}
double dist_seg_seg(pair<complex<double>, complex<double> > a,
                    pair<complex<double>, complex<double> > b) {
  double res;
  for (int i = 0; i < 2; i++) {
    res = min(dist_pts_seg(a.first, b), dist_pts_seg(a.second, b));
    swap(a, b);
  }
  if (has_intersec_seg_seg(a, b)) res = 0;
  return res;
}
int N, M, L;
vector<vector<pair<complex<double>, complex<double> > > > star;
double edge[120][120];
void init() {
  star.clear();
  for (int i = 0; i < (120); i++) {
    for (int j = 0; j < (120); j++) edge[i][j] = 1e9;
    edge[i][i] = 0;
  }
}
int main() {
  while (cin >> N >> M >> L, N || M || L) {
    init();
    M--;
    L--;
    for (int i = 0; i < (N); i++) {
      int x, y, a, r;
      cin >> x >> y >> a >> r;
      vector<complex<double> > tmp;
      double theta = (a + 90) / 180.0 * M_PI;
      double phi = 360.0 / 5.0 / 180.0 * M_PI;
      for (int i = 0; i < (5); i++) {
        tmp.push_back(polar((double)r, theta + phi * i) +
                      complex<double>(x, y));
      }
      vector<pair<complex<double>, complex<double> > > push;
      for (int i = 0; i < (5); i++) {
        push.push_back(
            pair<complex<double>, complex<double> >(tmp[i], tmp[(i + 2) % 5]));
      }
      star.push_back(push);
    }
    for (int i = 0; i < (N); i++) {
      for (int j = i + 1; j < N; j++) {
        double tmp = 1e9;
        for (int k = 0; k < (5); k++) {
          for (int l = 0; l < (5); l++) {
            tmp = min(tmp, dist_seg_seg(star[i][k], star[j][l]));
          }
        }
        edge[i][j] = edge[j][i] = tmp;
      }
    }
    for (int i = 0; i < (N); i++) {
      for (int j = 0; j < (N); j++) {
        for (int k = 0; k < (N); k++) {
          edge[j][k] = min(edge[j][k], edge[j][i] + edge[i][k]);
        }
      }
    }
    printf("%.10lf\n", edge[L][M]);
  }
}
