#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-9;
struct Line {
  complex<double> pos, dir;
  Line() {}
  Line(const complex<double>& pos, const complex<double>& dir) {
    this->pos = pos;
    this->dir = dir;
  }
};
double convertD2R(double deg) { return (deg * PI) / 180.0; }
double dot(const complex<double>& a, const complex<double>& b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
double cross(const complex<double>& a, const complex<double>& b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
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;
}
complex<double> projection(const Line& l, const complex<double>& p) {
  double t = dot(p - l.pos, l.pos - l.dir) / norm(l.pos - l.dir);
  return l.pos + t * (l.pos - l.dir);
}
bool intersectSP(const Line& s, const complex<double>& p) {
  return (abs(s.pos - p) + abs(s.dir - p) - abs(s.dir - s.pos) < EPS);
}
bool intersectSS(const Line& a, const Line& b) {
  return (ccw(a.pos, a.dir, b.pos) * ccw(a.pos, a.dir, b.dir) <= 0 &&
          ccw(b.pos, b.dir, a.pos) * ccw(b.pos, b.dir, a.dir) <= 0);
}
double distanceSP(const Line& s, const complex<double>& p) {
  complex<double> r = projection(s, p);
  if (intersectSP(s, r)) return abs(r - p);
  return min(abs(s.pos - p), abs(s.dir - p));
}
double distanceSS(const Line& a, const Line& b) {
  if (intersectSS(a, b)) return 0;
  return min(min(distanceSP(a, b.pos), distanceSP(a, b.dir)),
             min(distanceSP(b, a.pos), distanceSP(b, a.dir)));
}
struct Star {
  Line s[5];
  Star() {}
  Star(double x, double y, double a, double r) {
    int i;
    for ((i) = 0; (i) < (int)(5); (i)++) {
      double theta1 = convertD2R(a) + i * 2 * PI / 5.0 + PI / 2.0;
      double theta2 = convertD2R(a) + (i + 2) * 2 * PI / 5.0 + PI / 2.0;
      s[i] = (Line){polar(r, theta1) + complex<double>(x, y),
                    polar(r, theta2) + complex<double>(x, y)};
    }
  }
};
int V;
Star star[110];
priority_queue<pair<double, int> > q;
bool used[110];
double dist[110];
void add(int x, double d) {
  if (d < dist[x]) {
    dist[x] = d;
    q.push(make_pair(-d, x));
  }
}
void dijkstra(int start) {
  int next, i, j;
  for ((i) = 0; (i) < (int)(V); (i)++) used[i] = false;
  for ((i) = 0; (i) < (int)(V); (i)++) dist[i] = (1 << 29);
  add(start, 0.0);
  while (!q.empty()) {
    double d = -q.top().first;
    int now = q.top().second;
    q.pop();
    if (used[now]) continue;
    used[now] = true;
    for ((next) = 0; (next) < (int)(V); (next)++)
      if (now != next) {
        double d2 = (1 << 29);
        for ((i) = 0; (i) < (int)(5); (i)++)
          for ((j) = 0; (j) < (int)(5); (j)++)
            d2 = min(d2, distanceSS(star[now].s[i], star[next].s[j]));
        add(next, d + d2);
      }
  }
}
int main() {
  int start, goal, i;
  while (1) {
    cin >> V >> start >> goal;
    if (V == 0 && start == 0 && goal == 0) break;
    start--;
    goal--;
    for ((i) = 0; (i) < (int)(V); (i)++) {
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      star[i] = Star(x, y, a, r);
    }
    dijkstra(start);
    printf("%.17lf\n", dist[goal]);
  }
  return 0;
}
