#include <bits/stdc++.h>
using namespace std;
int N, M, L;
class Point {
 public:
  double x, y;
  Point(double x = 0, double y = 0) : 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*(Point p) { return Point(x * p.x, y * p.y); }
  Point operator/(Point p) { return Point(x / p.x, y / p.y); }
  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-7 && fabs(y - p.y) < 1e-7;
  }
};
vector<Point> Set[110];
double norm(Point p) { return p.x * p.x + p.y * p.y; }
double abs(Point p) { return sqrt(norm(p)); }
double cross(Point a, Point b) { return a.x * b.y - a.y * b.x; }
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y; }
double getDistance(Point a, Point b) { return abs(a - b); }
void make_coordinates(double x, double y, double a, double r, int ind) {
  Point s1, s2;
  s1.x = 0;
  s1.y = 0;
  s2.x = x;
  s2.y = y;
  Point s;
  double dir = M_PI * a / 180.0, pre = M_PI * 72.0 / 180.0;
  s.x = 0;
  s.y = r;
  for (int i = 0; i < 5; i++) {
    Point p;
    p.x = s.x * cos(dir + pre * i) - s.y * sin(dir + pre * i) + x;
    p.y = s.x * sin(dir + pre * i) + s.y * cos(dir + pre * i) + y;
    Set[ind].push_back(p);
  }
}
int main() {
  while (true) {
    cin >> N >> M >> L;
    if (N + M + L == 0) break;
    for (int i = 0; i < 110; i++) Set[i].clear();
    for (int i = 0; i < N; i++) {
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      make_coordinates(x, y, a, r, i);
    }
    double d[N * 5 + 6][N * 5 + 6];
    for (int i = 0; i < N * 5; i++)
      for (int j = 0; j < N * 5; j++) d[i][j] = 1 << 27;
    for (int i = 0; i < N; i++) {
      for (int k = 0; k < 5; k++) {
        for (int j = 0; j < N; j++) {
          for (int l = 0; l < 5; l++) {
            d[i * 5 + k][j * 5 + l] = d[j * 5 + l][i * 5 + k] =
                getDistance(Set[i][k], Set[j][l]);
            if (i == j) d[i * 5 + k][j * 5 + l] = d[j * 5 + l][i * 5 + k] = 0;
          }
        }
      }
    }
    for (int k = 0; k < N * 5; k++)
      for (int i = 0; i < N * 5; i++)
        for (int j = 0; j < N * 5; j++)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    double ans = 1 << 27;
    for (int i = 0; i < 5; i++) {
      for (int j = 0; j < 5; j++) {
        ans = min(d[(M - 1) * 5 + i][(L - 1) * 5 + j], ans);
      }
    }
    cout << setiosflags(ios::fixed) << setprecision(20) << ans << endl;
  }
  return 0;
}
