#include <bits/stdc++.h>
using namespace std;
int N, S, G = 0;
double l[110][110] = {};
double nowL[110] = {};
const double PI = 3.14159265358979;
struct Star {
  const int px, py, a;
  double x[5], y[5];
  Star(int _px, int _py, int _a, int _r) : px(_px), py(_py), a(_a) {
    for (int i = 0; i < 5; i++) {
      x[i] =
          px + _r * cos((90.0000000 + _a + i * 72.0000000) * PI / 180.00000000);
      y[i] =
          py + _r * sin((90.0000000 + _a + i * 72.0000000) * PI / 180.00000000);
    }
  };
};
Star* s[105];
double MinL(double x0, double y0, double x1, double y1, double x2, double y2) {
  double dx = x1 - x2, dy = y1 - y2;
  double x = (dx * dx * x0 - dx * dy * y0 + dy * (dx * y2 - dy * x2)) /
             (dx * dx - dy * dy);
  double d;
  if (min(x1, x2) <= x && x <= max(x1, x2)) {
    d = abs(dy * x0 - dx * y0 + x1 * y2 - x2 * y1) / hypot(dx, dy);
  } else {
    d = min(hypot(x1 - x0, y1 - y0), hypot(x2 - x0, y2 - y0));
  }
  return d;
}
bool Crossing(double x0, double y0, double x1, double y1, double x2, double y2,
              double x3, double y3) {
  double t1 = (x2 - x3) * (y0 - y2) + (y2 - y3) * (x2 - x0);
  double t2 = (x2 - x3) * (y1 - y2) + (y2 - y3) * (x2 - x1);
  double t3 = (x0 - x1) * (y2 - y0) + (y0 - y1) * (x0 - x2);
  double t4 = (x0 - x1) * (y3 - y0) + (y0 - y1) * (x0 - x3);
  return t3 * t4 <= 0 && t1 * t2 <= 0;
}
void CalcStar(int a, int b) {
  const unsigned lineGoal[5] = {2, 3, 4, 0, 1};
  double temp = 100000;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      if (Crossing(s[a]->x[i], s[a]->y[i], s[a]->x[lineGoal[i]],
                   s[a]->y[lineGoal[i]], s[b]->x[j], s[b]->y[j],
                   s[b]->x[lineGoal[j]], s[b]->y[lineGoal[j]])) {
        l[b][a] = l[a][b] = 0;
        return;
      }
    }
  }
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      temp = min(temp, MinL(s[a]->x[i], s[a]->y[i], s[b]->x[j], s[b]->y[j],
                            s[b]->x[lineGoal[j]], s[b]->y[lineGoal[j]]));
    }
  }
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      temp = min(temp, MinL(s[b]->x[i], s[b]->y[i], s[a]->x[j], s[a]->y[j],
                            s[a]->x[lineGoal[j]], s[a]->y[lineGoal[j]]));
    }
  }
  l[b][a] = l[a][b] = temp;
}
double minCost[110];
void Dijkstra(int _s, int _g) {
  for (int i = 1; i <= N; i++) {
    minCost[i] = 1000000;
  }
  minCost[_s] = 0;
  struct Node {
    int num;
    double cost;
    bool operator>(const Node& _node) const { return cost > _node.cost; }
  };
  priority_queue<Node, vector<Node>, greater<Node>> PQ;
  Node node = {_s, 0};
  PQ.push(node);
  while (!PQ.empty()) {
    Node now = PQ.top();
    PQ.pop();
    if (now.cost > minCost[now.num]) {
      continue;
    }
    minCost[now.num] = now.cost;
    if (now.num == _g) {
      return;
    }
    for (int i = 1; i <= N; i++) {
      if (i != now.num) {
        Node node = {i, now.cost + l[now.num][i]};
        PQ.push(node);
      }
    }
  }
}
int main() {
  while (true) {
    cin >> N >> S >> G;
    if (N == 0) {
      break;
    }
    for (int i = 1; i <= N; i++) {
      int x, y, a, r;
      cin >> x >> y >> a >> r;
      s[i] = new Star(x, y, a, r);
      nowL[i] = 5000;
    }
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        CalcStar(i, j);
      }
    }
    Dijkstra(S, G);
    cout << fixed << setprecision(7) << minCost[G] << endl;
    for (int i = 1; i <= N; i++) {
      delete s[i];
    }
  }
  return 0;
}
