#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chmin(T &l, T r) {
  bool res = l > r;
  if (res) {
    l = r;
  }
  return res;
}
const double EPS = 1e-8;
inline double dot(complex<double> a, complex<double> b) {
  return a.real() * b.real() + a.imag() * b.imag();
}
inline double cross(complex<double> a, complex<double> b) {
  return a.real() * b.imag() - a.imag() * b.real();
}
inline int sgn(complex<double> a, complex<double> b, complex<double> c) {
  if (cross(b - a, c - a) > EPS) return 1;
  if (cross(b - a, c - a) < -EPS) return -1;
  if (dot(b - a, c - a) < -EPS) return 2;
  if (dot(a - b, c - b) < -EPS) return -2;
  return 0;
}
struct cww {
  cww() {
    cout << fixed;
    cout << setprecision(10);
  }
} star;
inline double distance_P_LS(complex<double> p,
                            pair<complex<double>, complex<double>> ls) {
  complex<double> a, b, c = p;
  tie(a, b) = ls;
  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);
}
inline bool is_LS_LS(pair<complex<double>, complex<double>> p,
                     pair<complex<double>, complex<double>> q) {
  complex<double> a, b, c, d;
  tie(a, b) = p;
  tie(c, d) = q;
  return sgn(a, b, c) * sgn(a, b, d) <= 0 && sgn(c, d, a) * sgn(c, d, b) <= 0;
}
inline double distance_LS_LS(pair<complex<double>, complex<double>> p,
                             pair<complex<double>, complex<double>> q) {
  if (is_LS_LS) return 0;
  return min({distance_P_LS(p.first, q), distance_P_LS(p.second, q),
              distance_P_LS(q.first, p), distance_P_LS(q.second, p)});
}
complex<double> rot(complex<double> p, double r) {
  return complex<double>(p.real() * cos(r) - p.imag() * sin(r),
                         p.real() * sin(r) + p.imag() * cos(r));
}
const double PI = acos(-1);
const double FI = 72.0 / 180.0 * PI;
const int ss[][2] = {{0, 2}, {0, 3}, {1, 3}, {1, 4}, {2, 4}};
int main() {
  int N, M, L;
  while (cin >> N >> M >> L, N) {
    vector<pair<complex<double>, complex<double>>> ls(5 * N);
    for (int i = (0); i < (N); i++) {
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      complex<double> p(x, y);
      vector<complex<double>> pt(5);
      pt[0] = rot(complex<double>(0, r), a / 180.0 * PI);
      for (int i = (0); i < (4); i++) pt[i + 1] = rot(pt[i], FI);
      for (int j = (0); j < (5); j++) {
        ls[i * 5 + j] = pair<complex<double>, complex<double>>(
            p + pt[ss[j][0]], p + pt[ss[j][1]]);
      }
    }
    vector<vector<double>> dist(N * 5, vector<double>(N * 5));
    for (int i = (0); i < (5 * N); i++)
      for (int j = (0); j < (5 * N); j++) {
        if (i == j)
          dist[i][j] = 0;
        else
          dist[i][j] = distance_LS_LS(ls[i], ls[j]);
      }
    int S = 5 * (M - 1);
    int G = 5 * (L - 1);
    vector<double> res(N * 5, 1e18);
    res[S] = 0;
    priority_queue<pair<double, int>, vector<pair<double, int>>,
                   greater<pair<double, int>>>
        que;
    que.push(pair<double, int>(0, S));
    while (que.size()) {
      int v;
      double cost;
      tie(cost, v) = que.top();
      que.pop();
      if (cost > res[v]) continue;
      for (int u = (0); u < (5 * N); u++)
        if (u != v) {
          double ncost = cost + dist[u][v];
          if (chmin(res[u], ncost)) que.push(pair<double, int>(ncost, u));
        }
    }
    cout << res[G] << endl;
  }
  return 0;
}
