#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1);
namespace std {
bool operator<(const complex<double>& a, const complex<double>& b) {
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
}  // namespace std
double cross(const complex<double>& a, const complex<double>& b) {
  return imag(conj(a) * b);
}
double dot(const complex<double>& a, const complex<double>& b) {
  return real(conj(a) * b);
}
double dist2(const complex<double>& a, const complex<double>& b) {
  complex<double> c(b - a);
  return real(c) * real(c) + imag(c) * imag(c);
}
struct L : public vector<complex<double>> {
  L(const complex<double>& a, const complex<double>& b) {
    push_back(a);
    push_back(b);
  }
};
int ccw(complex<double> a, complex<double> b, complex<double> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > 0) return +1;
  if (cross(b, c) < 0) return -1;
  if (dot(b, c) < 0) return +2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
bool intersectSS(const L& s, const L& t) {
  return ccw(s[0], s[1], t[0]) * ccw(s[0], s[1], t[1]) <= 0 &&
         ccw(t[0], t[1], s[0]) * ccw(t[0], t[1], s[1]) <= 0;
}
double d[110][110];
int main() {
  int n, start, goal;
  while (cin >> n >> start >> goal && n && start && goal) {
    start--;
    goal--;
    for (int i = (int)0; i < (int)110; i++)
      for (int j = (int)0; j < (int)110; j++) d[i][j] = i == j ? 0.0 : 1e18;
    vector<vector<complex<double>>> p(n);
    for (int i = (int)0; i < (int)n; i++) {
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      a = PI * a / 180;
      for (int j = (int)0; j < (int)5; j++) {
        complex<double> t(cos(a + 2.0 * PI * j / 5.0 + PI / 2) * r + x,
                          sin(a + 2.0 * PI * j / 5.0 + PI / 2) * r + y);
        p[i].push_back(t);
      }
    }
    vector<vector<L>> l(n);
    for (int i = (int)0; i < (int)n; i++) {
      for (int j = (int)0; j < (int)5; j++) {
        int k = (j + 2) % 5;
        l[i].push_back({p[i][j], p[i][k]});
      }
    }
    for (int i = (int)0; i < (int)n; i++)
      for (int j = (int)0; j < (int)n; j++) {
        for (int a = (int)0; a < (int)5; a++)
          for (int b = (int)0; b < (int)5; b++)
            if (intersectSS(l[i][a], l[j][b])) d[i][j] = 0.0;
        for (int a = (int)0; a < (int)5; a++)
          for (int b = (int)0; b < (int)5; b++)
            d[i][j] = min(d[i][j], sqrt(dist2(p[i][a], p[j][b])));
      }
    for (int k = (int)0; k < (int)n; k++)
      for (int i = (int)0; i < (int)n; i++)
        for (int j = (int)0; j < (int)n; j++)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    printf("%.15lf\n", d[start][goal]);
  }
}
