#include <bits/stdc++.h>
using namespace std;
typedef double R;
int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
R dot(complex<R> a, complex<R> b) {
  return (a.real() * b.real() + a.imag() * b.imag());
}
R cross(complex<R> a, complex<R> b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}
bool is_orthogonal(pair<complex<R>, complex<R> > a,
                   pair<complex<R>, complex<R> > b) {
  return (abs((dot(a.first - a.second, b.first - b.second)) - (0.0)) < (1e-10));
}
bool is_parallel(pair<complex<R>, complex<R> > a,
                 pair<complex<R>, complex<R> > b) {
  return (abs((cross(a.first - a.second, b.first - b.second)) - (0.0)) <
          (1e-10));
}
int ccw(complex<R> a, complex<R> b, complex<R> c) {
  b -= a;
  c -= a;
  if (cross(b, c) > (1e-10)) return 1;
  if (cross(b, c) < -(1e-10)) return -1;
  if (dot(b, c) < -(1e-10)) return 2;
  if (norm(c) - norm(b) > (1e-10)) return -2;
  return 0;
}
bool is_intersection_ll(pair<complex<R>, complex<R> > l,
                        pair<complex<R>, complex<R> > m) {
  return abs(cross(l.second - l.first, m.second - m.first)) > (1e-10) ||
         abs(cross(l.second - l.first, m.first - l.first)) < (1e-10);
}
bool is_intersection_ls(pair<complex<R>, complex<R> > l,
                        pair<complex<R>, complex<R> > s) {
  return cross(l.second - l.first, s.first - l.first) *
             cross(l.second - l.first, s.second - l.first) <
         (1e-10);
}
bool is_intersection_lp(pair<complex<R>, complex<R> > l, complex<R> p) {
  return abs(cross(l.second - p, l.first - p));
}
bool is_intersection_ss(pair<complex<R>, complex<R> > a,
                        pair<complex<R>, complex<R> > b) {
  return ccw(a.first, a.second, b.first) * ccw(a.first, a.second, b.second) <=
             0 &&
         ccw(b.first, b.second, a.first) * ccw(b.first, b.second, a.second) <=
             0;
}
bool is_intersection_sp(pair<complex<R>, complex<R> > s, complex<R> p) {
  return abs(s.first - p) + abs(s.second - p) - abs(s.first - s.second) <
         (1e-10);
}
R dis_lp(pair<complex<R>, complex<R> > l, complex<R> p) {
  return abs(cross(l.second - l.first, p - l.first)) / abs(l.second - l.first);
}
R dis_ll(pair<complex<R>, complex<R> > l, pair<complex<R>, complex<R> > m) {
  return is_intersection_ll(l, m) ? 0.0 : dis_lp(l, m.first);
}
R dis_ls(pair<complex<R>, complex<R> > l, pair<complex<R>, complex<R> > s) {
  if (is_intersection_ls(l, s)) return 0.0;
  return min(dis_lp(l, s.first), dis_lp(l, s.second));
}
R dis_sp(pair<complex<R>, complex<R> > s, complex<R> p) {
  if (dot(s.second - s.first, p - s.first) < (1e-10)) return abs(p - s.first);
  if (dot(s.first - s.second, p - s.second) < (1e-10)) return abs(p - s.second);
  return dis_lp(s, p);
}
R dis_ss(pair<complex<R>, complex<R> > s, pair<complex<R>, complex<R> > t) {
  if (is_intersection_ss(s, t)) return 0.0;
  return min(min(dis_sp(s, t.first), dis_sp(s, t.second)),
             min(dis_sp(t, s.first), dis_sp(t, s.second)));
}
complex<R> projection(pair<complex<R>, complex<R> > l, complex<R> p) {
  R t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
  return l.first + t * (l.first - l.second);
}
complex<R> reflection(pair<complex<R>, complex<R> > l, complex<R> p) {
  return p + 2.0 * (projection(l, p) - p);
}
complex<R> intersection_ll(pair<complex<R>, complex<R> > l,
                           pair<complex<R>, complex<R> > m) {
  R A = cross(l.second - l.first, m.second - m.first);
  R B = cross(l.second - l.first, l.second - m.first);
  if (abs(A) < (1e-10) && abs(B) < (1e-10)) return m.first;
  return m.first + B / A * (m.second - m.first);
}
pair<complex<R>, complex<R> > intersection_of_two_circles(
    pair<complex<R>, R> c1, pair<complex<R>, R> c2) {
  R a = abs(c2.first - c1.first);
  R b = c1.second;
  R c = c2.second;
  R rc = (a * a + b * b - c * c) / (2.0 * a);
  R rs = sqrt(b * b - rc * rc);
  complex<R> diff = (c2.first - c1.first) / a;
  pair<complex<R>, complex<R> > p;
  p.first = c1.first + diff * rc + diff * complex<R>(0, 1) * rs;
  p.second = c1.first + diff * rc + diff * complex<R>(0, -1) * rs;
  return p;
}
int is_contains_p_in_Poly(vector<complex<R> > po, complex<R> p) {
  bool in = false;
  for (int i = 0; i < (po.size()); i++) {
    complex<R> a = po[i] - p, b = po[(i + 1) % po.size()] - p;
    if (a.imag() > b.imag()) swap(a, b);
    if (a.imag() < (1e-10) && -(1e-10) < b.imag())
      if (cross(a, b) < -(1e-10)) in = !in;
    if (abs(cross(a, b)) == 0.0 && dot(a, b) < (1e-10)) return -1;
  }
  return in;
}
R area2(vector<complex<R> > po) {
  R A = 0.0;
  for (int i = 0; i < (po.size()); i++)
    A += cross(po[i], po[(i + 1) % po.size()]);
  return A;
}
vector<complex<R> > convex_hull(vector<complex<R> > ps) {
  int n = ps.size(), k = 0;
  vector<complex<R> > ch(2 * n);
  for (int i = 0; i < n; ch[k++] = ps[i++])
    while (k >= 2 && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
  for (int i = n - 2, t = k + 1; i >= 0; ch[k++] = ps[i--])
    while (k >= t && ccw(ch[k - 2], ch[k - 1], ps[i]) <= 0) --k;
  ch.resize(k - 1);
  return ch;
}
bool isconvex(vector<complex<R> > P) {
  for (int i = 0; i < P.size(); ++i)
    if (ccw(P[(i + P.size() - 1) % P.size()], P[i], P[(i + 1) % P.size()]) > 0)
      return false;
  return true;
}
vector<complex<R> > rotate_poly(vector<complex<R> > po, complex<R> c, R a) {
  for (int i = 0; i < (po.size()); i++) {
    po[i] = complex<R>(po[i].real() - c.real(), po[i].imag() - c.imag());
    po[i] = po[i] * complex<R>(cos(a), sin(a));
    po[i] = complex<R>(po[i].real() + c.real(), po[i].imag() + c.imag());
  }
  return po;
}
R convert_deg_to_rad(R deg) { return deg / 180.0 * M_PI; }
int N, M, L;
vector<complex<R> > star[100];
bool input() {
  cin >> N >> M >> L;
  R x, y, a, r;
  for (int i = 0; i < (N); i++) {
    star[i].clear();
    cin >> x >> y >> a >> r;
    R ar = convert_deg_to_rad(a + 90.0);
    for (int j = 0; j < (5); j++) {
      star[i].push_back(complex<R>(x, y) + r * complex<R>(cos(ar), sin(ar)));
      ar += convert_deg_to_rad(72.0);
    }
  }
  return N != 0;
}
R G[100][100];
void solve() {
  fill((R *)G, (R *)G + 10000, 1000000000.0);
  for (int i = 0; i < (N); i++) {
    G[i][i] = 0.0;
  }
  R dis;
  for (int i = 0; i < (N); i++) {
    for (int j = (i + 1); j < (N); j++) {
      dis = 1000000000.0;
      for (int k = 0; k < (5); k++) {
        for (int l = 0; l < (5); l++) {
          dis = min(dis, dis_ss(pair<complex<R>, complex<R> >(
                                    star[i][k], star[i][(k + 2) % 5]),
                                pair<complex<R>, complex<R> >(
                                    star[j][l], star[j][(l + 2) % 5])));
        }
      }
      G[i][j] = dis;
      G[j][i] = dis;
    }
  }
  for (int k = 0; k < (N); k++) {
    for (int i = 0; i < (N); i++) {
      for (int j = 0; j < (N); j++) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  cout << G[M - 1][L - 1] << endl;
}
int main() {
  while (input()) {
    solve();
  }
  return 0;
}
