#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9, pi = acos(long double(-1.0));
long double dot(complex<long double> a, complex<long double> b) {
  return real(conj(a) * b);
}
long double cross(complex<long double> a, complex<long double> b) {
  return imag(conj(a) * b);
}
namespace std {
bool operator<(const complex<long double> &lhs,
               const complex<long double> &rhs) {
  return lhs.real() == rhs.real() ? lhs.imag() < rhs.imag()
                                  : lhs.real() < rhs.real();
}
}  // namespace std
class L {
 public:
  complex<long double> a, b;
  L(complex<long double> aa, complex<long double> bb) {
    a = aa;
    b = bb;
  }
  L(long double ax, long double ay, long double bx, long double by) {
    a = complex<long double>(ax, ay);
    b = complex<long double>(bx, by);
  }
};
int ccw(complex<long double> a, complex<long double> b,
        complex<long double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > eps) return 1;
  if (cross(b, c) < -eps) return -1;
  if (dot(b, c) < 0) return 2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
complex<long double> proj(L l, complex<long double> p) {
  long double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
  return l.a + t * (l.a - l.b);
}
bool isis_ss(L s, L t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
         ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}
bool isis_sp(L s, complex<long double> p) {
  return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}
long double dist_sp(L s, complex<long double> p) {
  complex<long double> r = proj(s, p);
  if (isis_sp(s, r)) return abs(r - p);
  return min(abs(s.a - p), abs(s.b - p));
}
long double dist_ss(L s, L t) {
  if (isis_ss(s, t)) return 0;
  return min(min(dist_sp(s, t.a), dist_sp(s, t.b)),
             min(dist_sp(t, s.a), dist_sp(t, s.b)));
}
struct Star {
  vector<L> lines;
};
long double d(Star s1, Star s2) {
  long double mind = 1000000000.0;
  for (int i = 0; i < (int)(5); i++)
    for (int j = 0; j < (int)(5); j++) {
      mind = min(mind, dist_ss(s1.lines[i], s2.lines[j]));
    }
  return mind;
}
int main() {
  while (1) {
    int n, m, l;
    cin >> n >> m >> l;
    --m;
    --l;
    vector<Star> s;
    if (!n) break;
    for (int i = 0; i < (int)(n); i++) {
      long double x, y, a, r;
      cin >> x >> y >> a >> r;
      complex<long double> p = polar<long double>(r, a / 180.0 * pi + pi / 2.0);
      complex<long double> c(x, y);
      Star st;
      for (int j = 0; j < (int)(5); j++) {
        st.lines.emplace_back(
            p * polar<long double>(1.0, 2.0 * j * pi / 2.5) + c,
            p * polar<long double>(1.0, 2.0 * (j + 2) * pi / 2.5) + c);
      }
      s.push_back(st);
    }
    vector<vector<long double>> dist(n, vector<long double>(n));
    for (int i = 0; i < (int)(n); i++)
      for (int j = 0; j < (int)(n); j++) {
        if (i == j) {
          dist[i][j] = 0.0;
        } else {
          dist[i][j] = d(s[i], s[j]);
        }
      }
    for (int k = 0; k < (int)(n); k++)
      for (int i = 0; i < (int)(n); i++)
        for (int j = 0; j < (int)(n); j++)
          dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    cout << setprecision(15) << fixed << dist[m][l] << endl;
  }
  return 0;
}
