#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toStr(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX / 10;
double rad(double deg) { return deg * PI / 180.0; }
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 is_point_on_line(complex<double> a, complex<double> b, complex<double> c) {
  return (abs((cross(b - a, c - a)) - (0.0)) < EPS);
}
int is_point_on_ls(complex<double> a, complex<double> b, complex<double> c) {
  return (abs(a - c) + abs(c - b) < abs(a - b) + EPS);
}
int is_intersected_ls(complex<double> a1, complex<double> a2,
                      complex<double> b1, complex<double> b2) {
  if ((cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < -EPS) &&
      (cross(b2 - b1, a1 - b1) * cross(b2 - b1, a2 - b1) < -EPS))
    return true;
  return is_point_on_ls(a1, a2, b1) || is_point_on_ls(a1, a2, b2) ||
         is_point_on_ls(b1, b2, a1) || is_point_on_ls(b1, b2, a2);
}
double distance_ls_p(complex<double> a, complex<double> b, complex<double> c) {
  if (dot(b - a, c - a) < -EPS) return abs(c - a);
  if (dot(a - b, c - b) < -EPS) return abs(c - b);
  return abs(cross(b - a, c - a)) / abs(b - a);
}
double distance_ls(complex<double> a1, complex<double> a2, complex<double> b1,
                   complex<double> b2) {
  if (is_intersected_ls(a1, a2, b1, b2)) {
    return 0.0;
  }
  return min(min(distance_ls_p(a1, a2, b1), distance_ls_p(a1, a2, b2)),
             min(distance_ls_p(b1, b2, a1), distance_ls_p(b1, b2, a2)));
}
int main() {
  int N, M, L;
  while (cin >> N >> M >> L, N) {
    vector<vector<complex<double> > > points(N, vector<complex<double> >(5));
    double x, y, a, r;
    for (int i = (0); i <= ((N)-1); ++i) {
      cin >> x >> y >> a >> r;
      for (int j = (0); j <= ((5) - 1); ++j) {
        points[i][j] = complex<double>(x - r * sin(rad(a + 72 * j)),
                                       y + r * cos(rad(a + 72 * j)));
      }
    }
    vector<vector<double> > cost(N, vector<double>(N, INF));
    for (int i = (0); i <= ((N)-1); ++i) {
      for (int j = (i + 1); j <= (N - 1); ++j) {
        for (int k = (0); k <= ((5) - 1); ++k) {
          for (int l = (0); l <= ((5) - 1); ++l) {
            cost[i][j] = cost[j][i] = min(
                cost[i][j], distance_ls(points[i][k], points[i][(k + 2) % 5],
                                        points[j][l], points[j][(l + 2) % 5]));
          }
        }
      }
    }
    for (int i = (0); i <= ((N)-1); ++i) {
      for (int j = (0); j <= ((N)-1); ++j) {
        for (int k = (0); k <= ((N)-1); ++k) {
          cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
        }
      }
    }
    if (M == L) {
      cost[M - 1][L - 1] = 0.0;
    }
    printf("%.8f\n", cost[M - 1][L - 1]);
  }
  return 0;
}
