#include <bits/stdc++.h>
using namespace std;
int N, M, L;
complex<double> pt[101][5];
double dp[101][101];
const double pi = 3.1415926535897932384626;
double cross(complex<double> x, complex<double> y) {
  return x.real() * y.imag() - x.imag() * y.real();
}
double dot(complex<double> x, complex<double> y) {
  return x.real() * y.real() + x.imag() * y.imag();
}
bool intersep(complex<double> l1, complex<double> l2, complex<double> r1,
              complex<double> r2) {
  if (cross(l2 - l1, r1 - l1) * cross(l2 - l1, r2 - l1) < 0) {
    if (cross(r2 - r1, l1 - r1) * cross(r2 - r1, l2 - r1) < 0) return true;
  }
  return false;
}
double get_len(complex<double> p, complex<double> l1, complex<double> l2) {
  if (dot(p - l1, l2 - l1) <= 0) return abs(p - l1);
  if (dot(p - l2, l1 - l2) <= 0) return abs(p - l2);
  double cr = cross(p - l1, l2 - l1);
  return (abs(cr) / abs(l2 - l1));
}
double get_min(int m, int n) {
  if (m == n) return 0;
  double mn = INT_MAX;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      if (intersep(pt[m][i], pt[m][(i + 2) % 5], pt[n][j],
                   pt[n][(j + 2) % 5])) {
        return 0.0;
      }
      mn = min(mn, get_len(pt[n][j], pt[m][i], pt[m][(i + 2) % 5]));
      mn = min(mn, get_len(pt[m][i], pt[n][j], pt[n][(j + 2) % 5]));
    }
  }
  return mn;
}
int main() {
  while (cin >> N >> M >> L, (N || M || L)) {
    for (int i = 0; i < N; i++) {
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      for (int j = 0; j < 5; j++) {
        double alpha = (18 + a + 72 * j) / 180.0 * pi;
        double s = sin(alpha);
        double c = cos(alpha);
        complex<double> add = complex<double>(r, 0.0) * complex<double>(c, s);
        pt[i][j] = complex<double>(x, y) + add;
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dp[i][j] = get_min(i, j);
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        for (int k = 0; k < N; k++) {
          dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
        }
      }
    }
    printf("%.20lf\n", dp[M - 1][L - 1]);
  }
  return 0;
}
