#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
struct UnionFind {
  vector<int> v;
  UnionFind(int n) : v(n) {
    for (int i = 0; i < n; i++) v[i] = i;
  }
  int find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
  void unite(int x, int y) { v[find(x)] = find(y); }
};
struct star {
  double x;
  double y;
  double a;
  double r;
};
int main() {
  int n, m, l;
  while (cin >> n >> m >> l, n) {
    m--;
    l--;
    vector<vector<pair<double, double>>> point(n,
                                               vector<pair<double, double>>(5));
    for (int i = 0; i < (int)(n); ++i) {
      double x;
      double y;
      double a;
      double r;
      cin >> x >> y >> a >> r;
      for (int j = 0; j < (int)(5); ++j) {
        point[i][j].first =
            x + cos((a + (double)j * 72.0 + 90.0) / 360.0 * M_PI * 2.0) * r;
        point[i][j].second =
            y + sin((a + (double)j * 72.0 + 90.0) / 360.0 * M_PI * 2.0) * r;
      }
    }
    vector<vector<double>> vvd(n, vector<double>(n, 1e9));
    for (int i = 0; i < (int)(n - 1); ++i)
      for (int j = (int)(i + 1); j < (int)(n); ++j)
        for (int k = 0; k < (int)(5); ++k)
          for (int o = 0; o < (int)(5); ++o) {
            vvd[i][j] =
                min(vvd[i][j], hypot(point[i][k].first - point[j][o].first,
                                     point[i][k].second - point[j][o].second));
            vvd[j][i] = vvd[i][j];
          }
    priority_queue<pair<double, int>> Q;
    vector<double> dpmin(n);
    for (int i = 0; i < (int)(n); ++i) dpmin[i] = -1e9;
    dpmin[m] = 0.0;
    Q.push({0.0, m});
    double ans;
    while (!Q.empty()) {
      pair<double, int> q = Q.top();
      Q.pop();
      if (q.second == l) {
        ans = -q.first;
        break;
      }
      for (int i = 0; i < (int)(n); ++i) {
        int now = q.second;
        if (now == i) continue;
        if (dpmin[i] < q.first - vvd[now][i]) {
          dpmin[i] = q.first - vvd[now][i];
          Q.push({q.first - vvd[now][i], i});
        }
      }
    }
    printf("%0.7lf\n", ans);
  }
}
