#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chadd(T &a, T b) {
  a = a + b;
}
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
constexpr long long INF = 1001001001001001LL;
constexpr long long MOD = 1000000007LL;
double deg2rad(double x) { return x * M_PI / 180.0; }
complex<double> rotatePoint(complex<double> a, complex<double> b, double z) {
  z = deg2rad(z);
  b -= a;
  double rx = b.real() * cos(z) - b.imag() * sin(z);
  double ry = b.real() * sin(z) + b.imag() * cos(z);
  complex<double> ret(rx, ry);
  ret += a;
  return ret;
}
long long int N, M, L;
double dist[110][110];
signed main() {
  while (cin >> N >> M >> L, N || M || L) {
    M--;
    L--;
    double x, y, a, r;
    vector<complex<double> > ps[110];
    for (long long int(i) = (0); (i) < (N); (i)++) {
      cin >> x >> y >> a >> r;
      complex<double> po = complex<double>(x, y),
                      pt = complex<double>(x, y + r);
      pt = rotatePoint(po, pt, a);
      for (long long int(j) = (0); (j) < (5); (j)++) {
        double deg = 72.0 * j;
        ps[i].push_back(rotatePoint(po, pt, deg));
      }
    }
    for (long long int(i) = (0); (i) < (N); (i)++)
      for (long long int(j) = (0); (j) < (N); (j)++) {
        dist[i][j] = INF;
        for (long long int(x) = (0); (x) < (5); (x)++)
          for (long long int(y) = (0); (y) < (5); (y)++) {
            complex<double> tx = ps[i][x], ty = ps[j][y];
            chmin(dist[i][j], abs(tx - ty));
          }
      }
    for (long long int(k) = (0); (k) < (N); (k)++)
      for (long long int(i) = (0); (i) < (N); (i)++)
        for (long long int(j) = (0); (j) < (N); (j)++) {
          chmin(dist[i][j], dist[i][k] + dist[k][j]);
        }
    printf("%.12f\n", dist[M][L]);
  }
  return 0;
}
