#include <bits/stdc++.h>
using namespace std;
struct Point {
  double x, y;
};
int main() {
  double a, b, c, d;
  int n, ve, al;
  while (cin >> n >> ve >> al, n) {
    Point p[n][5];
    for (int i = 0; i < n; i++) {
      cin >> a >> b >> c >> d;
      for (int j = 0; j < 5; j++) {
        p[i][j].x = a + d * sin(M_PI / 180 * 72 * j + c);
        p[i][j].y = b + d * cos(M_PI / 180 * 72 * j + c);
      }
    }
    double w[n][n];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) w[i][j] = i == j ? 0 : 1000000000;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++) {
        double t = 1000000000;
        for (int k = 0; k < 5; k++)
          for (int l = 0; l < 5; l++)
            t = min(t, sqrt(pow(p[i][k].x - p[j][l].x, 2) +
                            pow((p[i][k].y - p[j][l].y), 2)));
        w[i][j] = w[j][i] = t;
        cout << t << endl;
      }
    for (int k = 0; k < n; k++)
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
    printf("%.11f\n", w[ve - 1][al - 1]);
  }
}
