#include<bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> P;
typedef pair<double,int> D;

P p[100];
double r[100];
int a[100],n,s,g;

double cal(){
  for(int i=0;i<n;i++)cin>>p[i].x>>p[i].y>>a[i]>>r[i];
  priority_queue<D,vector<D>,greater<D> > Q;
  int used[100]={};
  Q.push(D(0,s-1));
  while(!Q.empty()){
    double cs=Q.top().first;
    int pos=Q.top().second;
    Q.pop();
    if(used[pos]++)continue;
    if(pos==g-1)return cs;
    for(int i=0;i<n;i++){
      if(i==pos)continue;
      for(int j=0;j<5;j++){
	double na=M_PI*(a[i]+72*j+90)/180;
	P S=P(r[i]*cos(na),r[i]*sin(na));
	for(int k=0;k<5;k++){
	  double nb=M_PI*(a[pos]+72*k+90)/180;
	  P G=P(r[pos]*cos(nb),r[pos]*sin(nb));
	  Q.push(D(cs+abs((S+p[i])-(G+p[pos])),i));
	  
	}
      }
    }
  } 
}

int main(){
  while(cin>>n>>s>>g,n)printf("%.8lf\n",cal());
  return 0;
}