#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double eps = 1e-10;
const double pi = acos(-1.0);
const long long INF = 1LL << 62;
const int inf = 1 << 30;
template <class T>
bool operator==(T a, T b) {
  return abs(a - b) < eps;
}
template <class T>
bool operator<(T a, T b) {
  return a < b - eps;
}
template <class T>
bool operator<=(T a, T b) {
  return a < b + eps;
}
template <class T>
int sig(T r) {
  return (r == 0 || r == -0) ? 0 : r > 0 ? 1 : -1;
}
typedef struct {
  complex<long double> c;
  long double r;
} C;
typedef struct {
  complex<long double> c;
  long double a, b;
} E;
inline bool cmp_x(const complex<long double> &a,
                  const complex<long double> &b) {
  return (abs(a.real() - b.real()) < eps) ? a.imag() < b.imag()
                                          : a.real() < b.real();
}
inline bool cmp_y(const complex<long double> &a,
                  const complex<long double> &b) {
  return (abs(a.imag() - b.imag()) < eps) ? a.real() < b.real()
                                          : a.imag() < b.imag();
}
inline bool cmp_a(const complex<long double> &a,
                  const complex<long double> &b) {
  return (abs(arg(a) - arg(b)) < eps) ? norm(a) < norm(b) : arg(a) < arg(b);
}
long double ip(complex<long double> a, complex<long double> b) {
  return a.real() * b.real() + a.imag() * b.imag();
}
long double ep(complex<long double> a, complex<long double> b) {
  return a.real() * b.imag() - a.imag() * b.real();
}
long double sr(long double a) { return sqrt(max(a, (long double)0)); }
complex<long double> vec(pair<complex<long double>, complex<long double>> l) {
  return l.second - l.first;
}
long double toRagian(long double degree) { return degree * pi / 180.0; }
long double ang(complex<long double> p) { return arg(p); }
long double ang(complex<long double> base, complex<long double> a,
                complex<long double> b) {
  return arg((b - base) / (a - base));
}
complex<long double> rot(complex<long double> base, complex<long double> a,
                         long double theta) {
  return base + polar(abs(a - base), arg(a - base) + theta);
}
complex<long double> proj(complex<long double> b, complex<long double> p) {
  return b * ip(b, p) / norm(b);
}
complex<long double> proj(pair<complex<long double>, complex<long double>> l,
                          complex<long double> p) {
  return l.first + proj(vec(l), p - l.first);
}
complex<long double> refl(pair<complex<long double>, complex<long double>> l,
                          complex<long double> p) {
  return proj(l, p) * long double(2.0) - p;
}
enum CCW {
  FRONT = 1,
  RIGHT = 2,
  BACK = 4,
  LEFT = 8,
  MID = 16,
  ON = FRONT | BACK | MID
};
inline int ccw(complex<long double> base, complex<long double> a,
               complex<long double> b) {
  a -= base;
  b -= base;
  if (ep(a, b) > eps) return LEFT;
  if (ep(a, b) < -eps) return RIGHT;
  if (ip(a, b) < -eps) return BACK;
  if (norm(a) < norm(b)) return FRONT;
  return MID;
}
bool iver(pair<complex<long double>, complex<long double>> a,
          pair<complex<long double>, complex<long double>> b) {
  return ip(vec(a), vec(b)) == 0.0;
}
bool ipar(pair<complex<long double>, complex<long double>> a,
          pair<complex<long double>, complex<long double>> b) {
  return ep(vec(a), vec(b)) == 0.0;
}
complex<long double> pLL(pair<complex<long double>, complex<long double>> a,
                         pair<complex<long double>, complex<long double>> b) {
  return a.first + vec(a) * ep(vec(b), b.first - a.first) / ep(vec(b), vec(a));
}
bool iLL(pair<complex<long double>, complex<long double>> l1,
         pair<complex<long double>, complex<long double>> l2) {
  return !ipar(l1, l2);
}
bool eqL(pair<complex<long double>, complex<long double>> a,
         pair<complex<long double>, complex<long double>> b) {
  return !iLL(a, b) && ep(vec(a), b.first - a.first) == 0;
}
bool iLS(pair<complex<long double>, complex<long double>> a,
         pair<complex<long double>, complex<long double>> b) {
  return sig(ep(vec(a), b.first - a.first)) *
             sig(ep(vec(a), b.second - a.first)) <=
         0;
}
bool iLSs(pair<complex<long double>, complex<long double>> a,
          pair<complex<long double>, complex<long double>> b) {
  return sig(ep(vec(a), b.first - a.first)) *
             sig(ep(vec(a), b.second - a.first)) <
         0;
}
bool iSS(pair<complex<long double>, complex<long double>> a,
         pair<complex<long double>, complex<long double>> b) {
  int cwa = ccw(a.first, a.second, b.first) | ccw(a.first, a.second, b.second);
  int cwb = ccw(b.first, b.second, a.first) | ccw(b.first, b.second, a.second);
  return ((cwa | cwb) & MID) || ((cwa & cwb) == (LEFT | RIGHT));
}
bool iSSs(pair<complex<long double>, complex<long double>> a,
          pair<complex<long double>, complex<long double>> b) {
  int cwa = ccw(a.first, a.second, b.first) | ccw(a.first, a.second, b.second);
  int cwb = ccw(b.first, b.second, a.first) | ccw(b.first, b.second, a.second);
  return (cwa & cwb) == (LEFT | RIGHT);
}
long double dLP(pair<complex<long double>, complex<long double>> l,
                complex<long double> p) {
  return abs(ep(vec(l), p - l.first)) / abs(vec(l));
}
long double dSP(pair<complex<long double>, complex<long double>> s,
                complex<long double> p) {
  if (sig(ip(vec(s), p - s.first)) <= 0) return abs(p - s.first);
  if (sig(ip(-vec(s), p - s.second)) <= 0) return abs(p - s.second);
  return dLP(s, p);
}
long double dLL(pair<complex<long double>, complex<long double>> a,
                pair<complex<long double>, complex<long double>> b) {
  return iLL(a, b) ? 0 : dLP(a, b.first);
}
long double dLS(pair<complex<long double>, complex<long double>> a,
                pair<complex<long double>, complex<long double>> b) {
  return iLS(a, b) ? 0 : min(dLP(a, b.first), dLP(a, b.second));
}
long double dSS(pair<complex<long double>, complex<long double>> a,
                pair<complex<long double>, complex<long double>> b) {
  return iSS(a, b) ? 0
                   : min(min(dSP(a, b.first), dSP(a, b.second)),
                         min(dSP(b, a.first), dSP(b, a.second)));
}
enum RCC {
  A_IN_B = 1,
  B_IN_A = 2,
  A_ON_B = 4,
  B_ON_A = 8,
  ISC = 16,
  ON_OUT = 32,
  OUT = 64,
  SAME = 12,
  ONS = 48
};
int rCC(C a, C b) {
  long double d = abs(a.c - b.c);
  int res = 0;
  if (a.r + b.r < d) res |= OUT;
  if (a.r + b.r == d) res |= ON_OUT;
  if (abs(a.r - b.r) < d && d < a.r + b.r) res |= ISC;
  if (d == b.r - a.r) res |= A_ON_B;
  if (d < b.r - a.r) res |= A_IN_B;
  if (d == a.r - b.r) res |= B_ON_A;
  if (d < a.r - b.r) res |= B_IN_A;
  return res;
}
vector<complex<long double>> pCC(C a, C b) {
  vector<complex<long double>> res;
  int rel = rCC(a, b);
  if (rel == SAME) {
    res.push_back(a.c + complex<long double>(a.r, 0));
    res.push_back(a.c + complex<long double>(-a.r, 0));
    res.push_back(a.c + complex<long double>(0, a.r));
    res.push_back(a.c + complex<long double>(0, -a.r));
  } else if (rel == ISC) {
    long double d = abs(b.c - a.c);
    long double x = (d * d + a.r * a.r - b.r * b.r) / (2 * d);
    complex<long double> e = (b.c - a.c) / abs(b.c - a.c),
                         w = e * complex<long double>(0, 1) *
                             sqrt(max(a.r * a.r - x * x, (long double)0));
    res.push_back(a.c + e * x - w);
    res.push_back(a.c + e * x + w);
  } else if (rel & ONS) {
    long double d = abs(b.c - a.c);
    long double x = (d * d + a.r * a.r - b.r * b.r) / (2 * d);
    complex<long double> e = (b.c - a.c) / abs(b.c - a.c);
    res.push_back(a.c + e * x);
  }
  return res;
}
vector<complex<long double>> pCL(
    C c, pair<complex<long double>, complex<long double>> l) {
  vector<complex<long double>> res;
  complex<long double> h = proj(l, c.c);
  complex<long double> e = vec(l) / abs(vec(l)) * sr(c.r * c.r - norm(h - c.c));
  res.push_back(h - e);
  res.push_back(h + e);
  return res;
}
pair<complex<long double>, complex<long double>> tanC(C c, long double t) {
  complex<long double> p = c.c + polar(c.r, t);
  complex<long double> d = polar(c.r, t) * complex<long double>(0, 1);
  return pair<complex<long double>, complex<long double>>(p - d, p + d);
}
vector<pair<complex<long double>, complex<long double>>> common_tan(C a, C b) {
  vector<pair<complex<long double>, complex<long double>>> res;
  long double d = ang(b.c - a.c);
  long double i = acos((a.r + b.r) / abs(b.c - a.c));
  long double o = acos((a.r - b.r) / abs(b.c - a.c));
  int r = rCC(a, b);
  if (r == OUT) {
    res.push_back(tanC(a, d + i));
    res.push_back(tanC(a, d - i));
  }
  if (r >= ISC) {
    res.push_back(tanC(a, d + o));
    res.push_back(tanC(a, d - o));
  }
  if (r & ONS) res.push_back(tanC(a, d));
  if (r == SAME) {
    for (int i = (0); i < (5); ++i) res.push_back(tanC(a, i));
  }
  return res;
}
int in_polygon(vector<complex<long double>> pol, complex<long double> p) {
  int n = pol.size();
  int res = 0;
  for (int i = (0); i < (n); ++i) {
    if (ccw(pol[i], pol[(i + 1) % n], p) == MID) return 1;
    if ((pol[i].imag() <= p.imag()) && (pol[(i + 1) % n].imag() > p.imag())) {
      long double vt = (p.imag() - pol[i].imag()) /
                       (pol[(i + 1) % n].imag() - pol[i].imag());
      long double dx = pol[(i + 1) % n].real() - pol[i].real();
      if (p.real() < pol[i].real() + vt * dx) res++;
    } else if ((pol[i].imag() > p.imag()) &&
               (pol[(i + 1) % n].imag() <= p.imag())) {
      long double vt = (p.imag() - pol[i].imag()) /
                       (pol[(i + 1) % n].imag() - pol[i].imag());
      long double dx = pol[(i + 1) % n].real() - pol[i].real();
      if (p.real() < pol[i].real() + vt * dx) res--;
    }
  }
  return res ? 2 : 0;
}
bool in_polygon(vector<complex<long double>> pol,
                pair<complex<long double>, complex<long double>> s) {
  vector<complex<long double>> check;
  int n = pol.size();
  for (int i = (0); i < (n); ++i) {
    pair<complex<long double>, complex<long double>> tar =
        pair<complex<long double>, complex<long double>>(pol[i],
                                                         pol[(i + 1) % n]);
    if (iSS(s, tar)) check.push_back(pLL(s, tar));
  }
  check.push_back(s.first);
  check.push_back(s.second);
  sort(check.begin(), check.end(), cmp_x);
  n = check.size();
  bool res = true;
  for (int i = (0); i < (n - 1); ++i) {
    complex<long double> m =
        (check[i] + check[i + 1]) / complex<long double>(2.0, 0.0);
    if (!in_polygon(pol, m)) res = false;
  }
  return res;
}
long double area(vector<complex<long double>> pol) {
  int n = pol.size();
  long double xx, yy, sum = 0.0;
  for (int i = (0); i < (n); ++i) {
    xx = pol[i % n].real() - pol[(i + 1) % n].real();
    yy = pol[i % n].imag() + pol[(i + 1) % n].imag();
    sum += xx * yy;
  }
  return abs(sum / 2.0);
}
vector<complex<long double>> convex_hull(vector<complex<long double>> pol) {
  int n = pol.size();
  sort(pol.begin(), pol.end(), cmp_x);
  vector<complex<long double>> res(2 * n);
  int k = 0;
  for (int i = (0); i < (n); ++i) {
    while (k > 1 && ep(res[k - 1] - res[k - 2], pol[i] - res[k - 1]) <= 0) k--;
    res[k++] = pol[i];
  }
  for (int i = n - 2, t = k; i >= 0; i--) {
    while (k > t && ep(res[k - 1] - res[k - 2], pol[i] - res[k - 1]) <= 0) k--;
    res[k++] = pol[i];
  }
  res.resize(k - 1);
  return res;
}
int main(void) {
  for (int n, s, z; cin >> n >> s >> z, n;) {
    s--, z--;
    vector<pair<complex<long double>, pair<int, int>>> stars(n);
    for (auto &&ss : stars) {
      int x, y;
      cin >> x >> y >> ss.second.first >> ss.second.second;
      ss.first = complex<long double>(x, y);
    }
    vector<vector<complex<long double>>> p;
    for (auto &&ss : stars) {
      vector<complex<long double>> cur(5);
      long double a = ss.second.first;
      int r = ss.second.second;
      complex<long double> root(0, r);
      for (int i = (0); i < (5); ++i) {
        cur[i] =
            rot(complex<long double>(0, 0), root, (a + 72 * i) / 180.0 * pi);
        cur[i] += ss.first;
      }
      p.push_back(cur);
    }
    vector<vector<long double>> minDist(n, vector<long double>(n, inf));
    for (int i = (0); i < (n); ++i) {
      for (int j = (0); j < (n); ++j) {
        for (int ii = (0); ii < (5); ++ii) {
          for (int jj = (0); jj < (5); ++jj) {
            minDist[i][j] = min(minDist[i][j],
                                sqrt(sqr(p[i][ii].real() - p[j][jj].real()) +
                                     sqr(p[i][ii].imag() - p[j][jj].imag())));
          }
        }
      }
    }
    for (int k = (0); k < (n); ++k) {
      for (int i = (0); i < (n); ++i) {
        for (int j = (0); j < (n); ++j) {
          minDist[i][j] = min(minDist[i][j], minDist[i][k] + minDist[k][j]);
        }
      }
    }
    printf("%.15Lf\n", minDist[s][z]);
  }
  return 0;
}
