#include <bits/stdc++.h>
using namespace std;
const int INFTY = 1 << 29;
const double EPS = 1e-9;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << '(' << p.first << ',' << p.second << ')';
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& a) {
  os << '[';
  for (int i = int(0); i < int(a.size()); i++) os << (i ? " " : "") << a[i];
  return os << ']';
}
int Signum(double x) { return abs(x) < EPS ? 0 : x < 0 ? -1 : 1; }
const double PI = acos(-1);
struct Point {
  double x, y;
  Point() {}
  Point(double x, double y) : x(x), y(y) {}
};
Point operator+(Point a, Point b) { return Point(a.x + b.x, a.y + b.y); }
Point operator-(Point a, Point b) { return Point(a.x - b.x, a.y - b.y); }
Point operator*(double c, Point p) { return Point(c * p.x, c * p.y); }
double Abs(Point p) { return sqrt(p.x * p.x + p.y * p.y); }
double Abs2(Point p) { return p.x * p.x + p.y * p.y; }
Point Rot(Point p, double t) {
  return Point(cos(t) * p.x - sin(t) * p.y, sin(t) * p.x + cos(t) * p.y);
}
double Dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double Cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
int CCW(Point a, Point b, Point c) {
  Point d1 = b - a, d2 = c - a;
  if (int sign = Signum(Cross(d1, d2))) return sign;
  if (Dot(d1, d2) < -EPS) return -2;
  if (Abs(d1) < Abs(d2) - EPS) return 2;
  return 0;
}
struct Line {
  Point pos, dir;
  Line() {}
  Line(Point p, Point d) : pos(p), dir(d) {}
  Line(double px, double py, double dx, double dy) : pos(px, py), dir(dx, dy) {}
};
Point Proj(Line l, Point p) {
  Point a = p - l.pos, b = l.dir;
  return l.pos + Dot(a, b) / Abs2(b) * b;
}
bool InterLS(Line l, Line s) {
  Point a = l.pos, b = l.pos + l.dir, c = s.pos, d = s.pos + s.dir;
  return CCW(a, b, c) * CCW(a, b, d) < 0;
}
bool InterSS(Line a, Line b) { return InterLS(a, b) && InterLS(b, a); }
double DistLP(Line l, Point p) { return Abs(Proj(l, p) - p); }
double DistSP(Line s, Point p) {
  int ccw = CCW(s.pos, s.pos + s.dir, Proj(s, p));
  if (ccw == -2) return Abs(p - s.pos);
  if (ccw == 2) return Abs(p - (s.pos + s.dir));
  return DistLP(s, p);
}
double DistLS(Line l, Line s) {
  if (InterLS(l, s)) return 0;
  return min(DistLP(l, s.pos), DistLP(l, s.pos + s.dir));
}
double DistSS(Line a, Line b) {
  if (InterSS(a, b)) return 0;
  double d1 = min(DistSP(a, b.pos), DistSP(a, b.pos + b.dir));
  double d2 = min(DistSP(b, a.pos), DistSP(b, a.pos + a.dir));
  return min(d1, d2);
}
int main() {
  for (int n, src, dst; cin >> n >> src >> dst, n | src | dst;) {
    vector<int> xs(n), ys(n), as(n), rs(n);
    for (int i = int(0); i < int(n); i++)
      cin >> xs[i] >> ys[i] >> as[i] >> rs[i];
    vector<vector<double> > dp(n, vector<double>(n, INFTY));
    for (int i = int(0); i < int(n); i++)
      for (int j = int(0); j < int(n); j++) {
        Point p1[6], p2[6];
        for (int k = int(0); k < int(6); k++) {
          p1[k] = Point(xs[i], ys[i]) +
                  Rot(Point(0, rs[i]), (as[i] + k * 144) * PI / 180);
          p2[k] = Point(xs[j], ys[j]) +
                  Rot(Point(0, rs[j]), (as[j] + k * 144) * PI / 180);
        }
        for (int k = int(0); k < int(5); k++)
          for (int l = int(0); l < int(5); l++) {
            Line s1(p1[k], p1[k + 1] - p1[k]);
            Line s2(p2[k], p2[k + 1] - p2[k]);
            dp[i][j] = min(dp[i][j], DistSS(s1, s2));
          }
      }
    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++)
          dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    cout << setiosflags(ios::fixed) << setprecision(15) << dp[src - 1][dst - 1]
         << endl;
  }
  return 0;
}
