#include <bits/stdc++.h>
using namespace std;
int main() {
  while (true) {
    long long int n, m, l;
    cin >> n >> m >> l;
    if (n == 0) break;
    vector<long long int> x, y, a, r;
    for (long long int i = 0; i < n; i++) {
      long long int in_x, in_y, in_a, in_r;
      cin >> in_x >> in_y >> in_a >> in_r;
      x.push_back(in_x);
      y.push_back(in_y);
      a.push_back(in_a);
      r.push_back(in_r);
    }
    double len[101][101];
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < n; j++) {
        len[i][j] = -1.00;
      }
      for (long long int p = 0; p < 5; p++) {
        double ang = M_PI * (a[i] + p * 72 + 90) / 180;
        double x0 = 1.00 * r[i] * cos(ang) + x[i];
        double y0 = 1.00 * r[i] * sin(ang) + y[i];
        for (long long int j = 0; j < n; j++) {
          for (long long int q = 0; q < 5; q++) {
            double ang = M_PI * (a[j] + q * 72 + 90) / 180;
            double x1 = 1.00 * r[j] * cos(ang) + x[j] - x0;
            double y1 = 1.00 * r[j] * sin(ang) + y[j] - y0;
            double k = sqrt(x1 * x1 + y1 * y1);
            if (len[i][j] < 0) {
              len[i][j] = k;
            } else {
              len[i][j] = min(len[i][j], k);
            }
          }
        }
      }
    }
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < n; j++) {
        for (long long int k = 0; k < n; k++) {
          len[i][j] = min(len[i][j], len[i][k] + len[k][j]);
        }
      }
    }
    cout << fixed << setprecision(10) << len[m - 1][l - 1] << endl;
  }
  return 0;
}
