#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
complex<double> p[110][5];
int n, m, l;
double x[110], y[110], z[110], r[110];
vector<pair<double, int> > g[110];
double d[110];
const complex<double> rotation =
    complex<double>(cos(72 * PI / 180), sin(72 * PI / 180));
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());
}
bool is_intersect(complex<double> a1, complex<double> a2, complex<double> b1,
                  complex<double> b2) {
  return (cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < 1e-10) &&
         (cross(b2 - b1, a1 - b1) * cross(b2 - b1, a2 - b1) < 1e-10);
}
double seg_dis(complex<double> a, complex<double> b, complex<double> c) {
  if (dot(b - a, c - a) < 1e-10) return abs(c - a);
  if (dot(a - b, c - b) < 1e-10) return abs(c - b);
  return abs(cross(b - a, c - a)) / abs(b - a);
}
double star_dis(int n1, int n2) {
  double dis = 1e9;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      double tmp = seg_dis(p[n1][i], p[n1][(i + 2) % 5], p[n2][j]);
      dis = min(dis, tmp);
    }
  }
  return dis;
}
void make_star(void) {
  for (int i = 0; i < n; i++) {
    p[i][0] = complex<double>(-r[i] * sin(z[i] * PI / 180),
                              r[i] * cos(z[i] * PI / 180));
    for (int j = 1; j < 5; j++) {
      p[i][j] = p[i][j - 1] * rotation;
    }
    for (int j = 0; j < 5; j++) {
      p[i][j] += complex<double>(x[i], y[i]);
    }
  }
}
void make_graph(void) {
  make_star();
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      bool f = false;
      for (int k1 = 0; k1 < 5; k1++) {
        for (int k2 = 0; k2 < 5; k2++) {
          f |= is_intersect(p[i][k1], p[i][(k1 * 2) % 5], p[j][k2],
                            p[j][(k2 + 2) % 5]);
          if (f) break;
        }
      }
      if (f) {
        g[i].push_back(pair<double, int>(0.0, j));
        g[j].push_back(pair<double, int>(0.0, i));
      } else {
        double star = min(star_dis(i, j), star_dis(j, i));
        g[i].push_back(pair<double, int>(star, j));
        g[j].push_back(pair<double, int>(star, i));
      }
    }
  }
}
int main() {
  while (cin >> n >> m >> l, (n || m || l)) {
    for (int i = 0; i < n; i++) {
      cin >> x[i] >> y[i] >> z[i] >> r[i];
    }
    for (int i = 0; i < n; i++) g[i].clear();
    make_graph();
    for (int i = 0; i < n; i++) d[i] = 1e9;
    d[m - 1] = 0.0;
    priority_queue<pair<double, int>, vector<pair<double, int> >,
                   greater<pair<double, int> > >
        q;
    q.push(pair<double, int>(0.0, m - 1));
    while (q.size()) {
      pair<double, int> p = q.top();
      q.pop();
      double cost = p.first;
      int pos = p.second;
      if (p.second == l - 1) break;
      for (int i = 0; i < g[pos].size(); i++) {
        double dis = cost + g[pos][i].first;
        int next = g[pos][i].second;
        if (dis + 1e-10 < d[next]) {
          d[next] = dis;
          q.push(pair<double, int>(dis, next));
        }
      }
    }
    printf("%.8lf\n", d[l - 1]);
  }
}
