#include <bits/stdc++.h>
using namespace std;
class Point {
 public:
  double x, y;
  Point(double x = -1, double y = -1) : x(x), y(y) {}
  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(a * x, a * y); }
  Point operator/(double a) { return Point(x / a, y / a); }
  bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const Point& p) const {
    return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
  }
  double norm() { return x * x + y * y; }
};
struct Segment {
  Point p1, p2;
  Segment(Point p1 = Point(-1, -1), Point p2 = Point(-1, -1))
      : p1(p1), p2(p2) {}
};
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; }
double norm(Point a) { return a.x * a.x + a.y * a.y; }
bool pequals(Point a, Point b) {
  return (fabs((a.x) - (b.x)) < (1e-10)) && (fabs((a.y) - (b.y)) < (1e-10));
}
Point rotate(Point a, double rad) {
  return Point(cos(rad) * a.x - sin(rad) * a.y,
               sin(rad) * a.x + cos(rad) * a.y);
}
double toRad(double agl) { return agl * M_PI / 180.0; }
int ccw(Point p0, Point p1, Point p2) {
  Point a = p1 - p0;
  Point b = p2 - p0;
  if (cross(a, b) > (1e-10)) return 1;
  if (cross(a, b) < -(1e-10)) return -1;
  if (dot(a, b) < -(1e-10)) return 2;
  if (norm(a) < norm(b)) return -2;
  return 0;
}
bool isIntersect(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
          ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
bool isIntersect(Segment s1, Segment s2) {
  return isIntersect(s1.p1, s1.p2, s2.p1, s2.p2);
}
double abs(Point a) { return sqrt(norm(a)); }
double getDistanceLP(Segment s, Point p) {
  return abs(cross(s.p2 - s.p1, p - s.p1)) / abs(s.p2 - s.p1);
}
double getDistanceSP(Segment s, Point p) {
  if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1);
  if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2);
  return getDistanceLP(s, p);
}
int N, M, L;
int main() {
  while (cin >> N >> M >> L, N | M | L) {
    vector<vector<Point> > info(N);
    vector<vector<double> > G(N, vector<double>(N));
    for (int i = 0; i < N; i++)
      for (int j = 0; j < N; j++) G[i][j] = (i == j ? 0 : (1 << 29));
    for (int i = 0; i < N; i++) {
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      for (int j = 0; j < 5; j++) {
        Point p = Point(0, r);
        p = rotate(p, toRad(a + 72 * j));
        info[i].push_back(Point(p.x + x, p.y + y));
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        double mincost = (1 << 29);
        for (int k = 0; k < 5; k++) {
          for (int l = 0; l < 5; l++) {
            if (isIntersect(Segment(info[i][k], info[i][(k + 2) % 5]),
                            Segment(info[j][l], info[j][(l + 2) % 5])) ||
                isIntersect(Segment(info[i][k], info[i][(k + 2) % 5]),
                            Segment(info[j][l], info[j][(l + 3) % 5]))) {
              mincost = 0;
              break;
            }
            if (isIntersect(Segment(info[i][k], info[i][(k + 3) % 5]),
                            Segment(info[j][l], info[j][(l + 2) % 5])) ||
                isIntersect(Segment(info[i][k], info[i][(k + 3) % 5]),
                            Segment(info[j][l], info[j][(l + 3) % 5]))) {
              mincost = 0;
              break;
            }
          }
          if (mincost == 0) break;
        }
        if (mincost == 0) goto Next;
        for (int k = 0; k < 5; k++) {
          for (int l = 0; l < 5; l++) {
            mincost =
                min(mincost,
                    min(getDistanceSP(Segment(info[j][l], info[j][(l + 2) % 5]),
                                      info[i][k]),
                        getDistanceSP(Segment(info[j][l], info[j][(l + 3) % 5]),
                                      info[i][k])));
          }
        }
      Next:;
        G[i][j] = G[j][i] = mincost;
      }
    }
    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 << setiosflags(ios::fixed) << setprecision(10) << G[M - 1][L - 1]
         << endl;
  }
  return 0;
}
