#include <bits/stdc++.h>
using namespace std;
const double pi = atan(1.0) * 4.0;
const double EPS = 1e-8;
double cross(pair<double, double> x, pair<double, double> y) {
  return x.first * y.second - x.second * y.first;
}
double dist(pair<double, double> x, pair<double, double> y) {
  return sqrt((x.first - y.first) * (x.first - y.first) +
              (x.second - y.second) * (x.second - y.second));
}
int main() {
  int N, M, L;
  while (scanf("%d %d %d", &N, &M, &L), N) {
    vector<vector<pair<double, double> > > star(N);
    for (int i = 0; i < N; i++) {
      int x, y, a, r;
      scanf("%d %d %d %d", &x, &y, &a, &r);
      for (int j = 0; j < 5; j++) {
        double ang = (72.0 * j + a) * pi / 180.0;
        pair<double, double> p(x - r * sin(ang), y + r * cos(ang));
        star[i].push_back(p);
      }
    }
    double cost[100][100];
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cost[i][j] = 1e9;
        if (i == j) cost[i][j] = 0.0;
        for (int ii = 0; ii < 5; ii++) {
          pair<double, double> v1 = pair<double, double>(
              star[i][ii].first - star[i][(ii + 2) % 5].first,
              star[i][ii].second - star[i][(ii + 2) % 5].second);
          for (int jj = 0; jj < 5; jj++) {
            pair<double, double> v2 = pair<double, double>(
                star[j][jj].first - star[j][(jj + 2) % 5].first,
                star[j][jj].second - star[j][(jj + 2) % 5].second);
            pair<double, double> u1 = pair<double, double>(
                star[i][ii].first - star[j][(jj + 2) % 5].first,
                star[i][ii].second - star[j][(jj + 2) % 5].second);
            pair<double, double> u2 = pair<double, double>(
                star[j][jj].first - star[i][(ii + 2) % 5].first,
                star[j][jj].second - star[i][(ii + 2) % 5].second);
            pair<double, double> w1 =
                pair<double, double>(star[i][ii].first - star[j][jj].first,
                                     star[i][ii].second - star[j][jj].second);
            pair<double, double> w2 =
                pair<double, double>(-w1.first, -w1.second);
            if (cross(v1, u1) * cross(v1, w1) < -EPS &&
                cross(v2, u2) * cross(v2, w2) < -EPS) {
              cost[i][j] = 0.0;
            }
          }
        }
        for (int ii = 0; ii < 5; ii++) {
          pair<double, double> s = star[i][ii];
          pair<double, double> t = star[i][(ii + 2) % 5];
          double alp = 0.0f;
          if (abs(t.first - s.first) < EPS) {
            for (int jj = 0; jj < 5; jj++) {
              cost[i][j] = min(cost[i][j], abs(t.first - star[j][jj].first));
            }
          } else {
            alp = (t.second - s.second) / (t.first - s.first);
            for (int jj = 0; jj < 5; jj++) {
              pair<double, double> p = star[j][jj];
              double qx = (p.first + alp * p.second - alp * s.second +
                           alp * alp * s.first) /
                          (alp * alp + 1.0);
              double qy = alp * (qx - s.first) + s.second;
              pair<double, double> q = pair<double, double>(qx, qy);
              if (dist(q, s) < dist(t, s) && dist(q, t) < dist(t, s)) {
                cost[i][j] = min(cost[i][j], dist(p, q));
              }
            }
          }
        }
        for (int ii = 0; ii < 5; ii++) {
          for (int jj = 0; jj < 5; jj++) {
            cost[i][j] = min(cost[i][j], dist(star[i][ii], star[j][jj]));
          }
        }
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        cost[i][j] = cost[j][i] = min(cost[i][j], cost[j][i]);
      }
    }
    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        }
      }
    }
    printf("%.10lf\n", min(cost[M - 1][L - 1], cost[L - 1][M - 1]));
  }
  return 0;
}
