#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
const long long MOD = 1e9 + 7;
long long sq(long long num) { return num * num; }
long long mod_pow(long long x, long long n) {
  if (n == 0) return 1;
  if (n == 1) return x % MOD;
  long long res = sq(mod_pow(x, n / 2));
  res %= MOD;
  if (n % 2 == 1) {
    res *= x;
    res %= MOD;
  }
  return res;
}
long long mod_add(long long a, long long b) { return (a + b) % MOD; }
long long mod_sub(long long a, long long b) { return (a - b + MOD) % MOD; }
long long mod_mul(long long a, long long b) { return a * b % MOD; }
long long n, m, l;
vector<complex<double>> p[110];
double dist(complex<double> p) { return abs(p); }
double dist(complex<double> a, complex<double> b) { return abs(a - b); }
complex<double> rot(complex<double> p, double a) {
  double x1 = p.real(), y1 = p.imag();
  return complex<double>(x1 * cos(a) - y1 * sin(a), x1 * sin(a) + y1 * cos(a));
}
class DK {
 public:
  struct edge {
    int to;
    double cost;
  };
  double d[100010];
  vector<edge> G[100010];
  void clear() {
    for (int i = 0; i < (100010); i++) G[i].clear();
  }
  void dijkstra(int start) {
    fill(d, d + 100010, INF);
    d[start] = 0;
    priority_queue<pair<long long, long long>,
                   vector<pair<long long, long long>>,
                   greater<pair<long long, long long>>>
        que;
    que.push(pair<long long, long long>(0, start));
    while (!que.empty()) {
      pair<long long, long long> p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first) continue;
      for (int i = 0; i < G[v].size(); i++) {
        edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(pair<long long, long long>(d[e.to], e.to));
        }
      }
    }
  }
};
DK dk;
int main() {
  while (cin >> n >> m >> l && n + m + l) {
    m--;
    l--;
    for (int i = 0; i < (110); i++) p[i].clear();
    dk.clear();
    for (int i = 0; i < (n); i++) {
      double x, y, a, r;
      cin >> x >> y >> a >> r;
      complex<double> po = complex<double>(0, r);
      po = rot(po, 2 * acos(-1.0) * a / 360);
      for (int j = 0; j < (5); j++) {
        p[i].push_back(po + complex<double>(x, y));
        po = rot(po, 2 * acos(-1.0) / 5);
      }
    }
    for (int i = 0; i < (n); i++) {
      for (int j = (i + 1); j < (n); j++) {
        double mind = INF;
        for (int k = 0; k < (p[i].size()); k++) {
          for (int l = 0; l < (p[j].size()); l++) {
            mind = min(dist(p[i][k], p[j][l]), mind);
          }
        }
        dk.G[i].push_back({j, mind});
        dk.G[j].push_back({i, mind});
      }
    }
    dk.dijkstra(m);
    printf("%.10lf\n", dk.d[l]);
  }
}
