#include <bits/stdc++.h>
int main(void) {
  int i, j, k, l;
  int n, vega, altair;
  while (scanf("%d %d %d", &n, &vega, &altair), n) {
    int x[100], y[100], a[100], r[100];
    double xx[100][5], yy[100][5];
    double d[100][100];
    for (i = 0; i < n; i++) scanf("%d %d %d %d", x + i, y + i, a + i, r + i);
    for (i = 0; i < n; i++)
      for (j = 0; j < 5; j++) {
        const double theta =
            (90. + 72. * j + a[i]) * 3.1415926535897932384626 / 180.;
        xx[i][j] = r[i] * cos(theta) + x[i];
        yy[i][j] = r[i] * sin(theta) + y[i];
      }
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) d[i][j] = i == j ? 0 : 1e10;
    for (i = 0; i < n; i++)
      for (j = i + 1; j < n; j++) {
        double min = 1e10;
        for (k = 0; k < 5; k++)
          for (l = 0; l < 5; l++)
            min =
                (((min) <
                  (sqrt(((xx[i][k] - xx[j][l]) * (xx[i][k] - xx[j][l])) +
                        ((yy[i][k] - yy[j][l]) * (yy[i][k] - yy[j][l])))))
                     ? (min)
                     : (sqrt(((xx[i][k] - xx[j][l]) * (xx[i][k] - xx[j][l])) +
                             ((yy[i][k] - yy[j][l]) * (yy[i][k] - yy[j][l])))));
        d[i][j] = d[j][i] = min;
      }
    for (k = 0; k < n; k++)
      for (i = 0; i < n; i++)
        for (j = 0; j < n; j++)
          d[i][j] = (((d[i][j]) < (d[i][k] + d[k][j])) ? (d[i][j])
                                                       : (d[i][k] + d[k][j]));
    printf("%.20f\n", d[vega - 1][altair - 1]);
  }
  return 0;
}
