#include <bits/stdc++.h>
using namespace std;
struct vec2d {
  long double x, y;
  vec2d() {}
  long double add(long double a, long double b) {
    if (abs(a + b) < 1.0e-9 * (abs(a) + abs(b))) return 0.0;
    return a + b;
  }
  vec2d(long double x, long double y) { this->x = x, this->y = y; }
  vec2d operator+(const vec2d& ope) {
    vec2d tmp;
    tmp.x = add(x, ope.x);
    tmp.y = add(y, ope.y);
    return tmp;
  }
  vec2d operator-(const vec2d& ope) {
    vec2d tmp;
    tmp.x = add(x, -ope.x);
    tmp.y = add(y, -ope.y);
    return tmp;
  }
  vec2d operator*(const long double& t) {
    vec2d tmp;
    tmp.x = x * t;
    tmp.y = y * t;
    return tmp;
  }
  long double dot(const vec2d& ope) { return add(x * ope.x, y * ope.y); }
  long double cross(const vec2d& ope) { return add(x * ope.y, -y * ope.x); }
};
bool PonL(vec2d p, vec2d q, vec2d c) {
  return (p - c).cross(q - c) == 0 && (p - c).dot(q - c) <= 0;
}
long double distPP(vec2d p, vec2d q) { return sqrt((p - q).dot(p - q)); }
long double distLP(vec2d p, vec2d q, vec2d c) {
  if ((q - p).dot(c - p) <= 0) return distPP(p, c);
  if ((p - q).dot(c - q) <= 0) return distPP(q, c);
  return fabs((q - p).cross(c - p) / distPP(p, q));
}
long double distLL(vec2d p, vec2d q, vec2d r, vec2d s) {
  if ((q - p).cross(s - r) == 0) {
    if (PonL(p, q, r) || PonL(p, q, s) || PonL(r, s, p) || PonL(r, s, q))
      return 0.0;
  } else {
    long double t = (r - p).cross(s - r) / (q - p).cross(s - r);
    vec2d c = p + (q - p) * t;
    if (PonL(p, q, c) && PonL(r, s, c)) return 0.0;
  }
  long double ret = 1.0e9;
  ret = min(ret, distLP(p, q, r));
  ret = min(ret, distLP(p, q, s));
  ret = min(ret, distLP(r, s, p));
  ret = min(ret, distLP(r, s, q));
  return ret;
}
int N, M, L;
int x[105], y[105], a[105], r[105];
vec2d star[105][5];
long double dist[105][105];
long double dijkstra() {
  long double d[105];
  bool used[105];
  for (int i = 0; i < N; i++) {
    d[i] = 1.0e9;
    used[i] = false;
  }
  d[M] = 0;
  int min_i, min_d;
  while (1) {
    min_d = 1.0e9;
    min_i = -1;
    for (int i = 0; i < N; i++) {
      if (used[i]) continue;
      if (min_d > d[i]) {
        min_d = d[i];
        min_i = i;
      }
    }
    if (min_i == -1) break;
    used[min_i] = true;
    for (int i = 0; i < N; i++) {
      if (used[i]) continue;
      d[i] = min(d[i], d[min_i] + dist[min_i][i]);
    }
  }
  return d[L];
}
long double distanceStar(int S, int T) {
  long double ret = 1.0e9;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      ret = min(ret, distLL(star[S][i * 2 % 5], star[S][(i + 1) * 2 % 5],
                            star[T][j * 2 % 5], star[T][(j + 1) * 2 % 5]));
    }
  }
  return ret;
}
int main(void) {
  while (1) {
    cin >> N >> M >> L;
    if (N == 0 && M == 0 && L == 0) break;
    M--, L--;
    for (int i = 0; i < N; i++) {
      cin >> x[i] >> y[i] >> a[i] >> r[i];
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < 5; j++) {
        star[i][j].x = x[i] + r[i] * cos((j * 72 + a[i] + 90) * M_PI / 180.0);
        star[i][j].y = y[i] + r[i] * sin((j * 72 + a[i] + 90) * M_PI / 180.0);
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = distanceStar(i, j);
      }
    }
    printf("%.12f\n", dijkstra());
  }
  return 0;
}
