#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const double eps = 1e-10;
double add(double a, double b) {
  if (abs(a + b) < eps * (abs(a) + abs(b))) return 0;
  return a + b;
}
pair<double, double> operator+(const pair<double, double>& x,
                               const pair<double, double>& y) {
  return {add(x.first, y.first), add(x.second, y.second)};
}
pair<double, double> operator-(const pair<double, double>& x,
                               const pair<double, double>& y) {
  return {add(x.first, -y.first), add(x.second, -y.second)};
}
pair<double, double> operator*(const pair<double, double>& x, const double& y) {
  return {x.first * y, x.second * y};
}
double dot(pair<double, double> x, pair<double, double> y) {
  return add(x.first * y.first, x.second * y.second);
}
double det(pair<double, double> x, pair<double, double> y) {
  return add(x.first * y.second, -x.second * y.first);
}
bool onseg(pair<double, double> p1, pair<double, double> p2,
           pair<double, double> q) {
  return det(p1 - q, p2 - q) == 0 && dot(p1 - q, p2 - q) <= 0;
}
pair<double, double> intersection(pair<double, double> p1,
                                  pair<double, double> p2,
                                  pair<double, double> q1,
                                  pair<double, double> q2) {
  return p1 + (p2 - p1) * (det(q2 - q1, q1 - p1) / det(q2 - q1, p2 - p1));
}
bool cross(pair<double, double> p1, pair<double, double> p2,
           pair<double, double> q1, pair<double, double> q2) {
  if (det(p1 - p2, q1 - q2) == 0)
    return onseg(p1, p2, q1) || onseg(p1, p2, q2) || onseg(q1, q2, p1) ||
           onseg(q1, q2, p2);
  pair<double, double> ret = intersection(p1, p2, q1, q2);
  return onseg(p1, p2, ret) && onseg(q1, q2, ret);
}
double dist(pair<double, double> p1, pair<double, double> p2,
            pair<double, double> q) {
  if (dot(q - p1, p2 - p1) <= 0) return sqrt(dot(q - p1, q - p1));
  if (dot(q - p2, p1 - p2) <= 0) return sqrt(dot(q - p2, q - p2));
  pair<double, double> d = p1 - p2;
  pair<double, double> ret = q + pair<double, double>{d.second, -d.first};
  pair<double, double> h = intersection(p1, p2, q, ret);
  return sqrt(dot(q - h, q - h));
}
const double pi = acos(-1);
int main() {
  int n, m, l;
  while (cin >> n >> m >> l) {
    if (n == 0) break;
    pair<double, double> x[n][5];
    for (int i = (int)0; i < (int)n; i++) {
      pair<double, double> c;
      cin >> c.first >> c.second;
      double a, b;
      cin >> a >> b;
      a *= pi / 180;
      for (int j = (int)0; j < (int)5; j++) {
        pair<double, double> y;
        y = {-sin(a + 2.0 / 5.0 * j * pi), cos(a + 2.0 / 5.0 * j * pi)};
        x[i][j] = c + y * b;
      }
    }
    double d[n][n];
    for (int i = (int)0; i < (int)n; i++)
      for (int j = (int)0; j < (int)n; j++) d[i][j] = inf;
    for (int i = (int)0; i < (int)n; i++) d[i][i] = 0;
    for (int i = (int)0; i < (int)n; i++)
      for (int j = (int)0; j < (int)n; j++) {
        if (i == j) continue;
        for (int k = (int)0; k < (int)5; k++)
          for (int l = (int)0; l < (int)5; l++) {
            d[i][j] = min(d[i][j], dist(x[i][k], x[i][(k + 2) % 5], x[j][l]));
            if (cross(x[i][k], x[i][(k + 2) % 5], x[j][l], x[j][(l + 2) % 5]))
              d[i][j] = 0;
          }
      }
    for (int i = (int)0; i < (int)n; i++)
      for (int j = (int)0; j < (int)n; j++)
        for (int k = (int)0; k < (int)n; k++)
          d[j][k] = min(d[j][k], d[i][j] + d[i][k]);
    cout << fixed << setprecision(12) << d[m - 1][l - 1] << endl;
  }
  return 0;
}
