#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<cmath>
#include<complex>
#define INF 10000000.0
#define pb push_back
using namespace std;
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
typedef __int64 ll;
typedef complex<double> Point;
typedef pair<double ,int > P;
const double PI=4*atan(1);
vector<vector<Point> > p;
int n,s,g;
double dot(Point a, Point b){
    return real( conj(a) * b );
}
double cross(Point a, Point b){
    return imag( conj(a) * b );
}
double distance_ls_p(Point a, Point b, Point c) {
  if ( dot(b-a, c-a)<=0 ) return abs(c-a);
  if ( dot(a-b, c-b)<=0 ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}
double cal(int a,int b){
	double ret=INF;
	for(int i=0;i<5;i++){
		for(int j=i+1;j<5;j++){
			for(int k=0;k<5;k++){
				//cout<<distance_ls_p(p[a][i],p[a][j],p[b][k])<<endl;
				//cout<<distance_ls_p(p[b][i],p[b][j],p[a][k])<<endl;
				double u=distance_ls_p(p[a][i],p[a][j],p[b][k]),v=distance_ls_p(p[b][i],p[b][j],p[a][k]);
				if(ret>u)
				ret=u;
				if(ret>v)
				ret=v;
			}
		}
	}
	//cout<<ret<<endl;
	return ret;
}



int main(){
	while(cin>>n>>s>>g,n||s||g){
		p.clear();
		p.resize(n);
		for(int i=0;i<n;i++){
			double x,y,a,r;
			Point pot;
			cin>>x>>y>>a>>r;
			Point c=Point(x,y);
			for(int j=0;j<5;j++){
				p[i].pb(c+polar(r,PI*(a+(double)j*72.0+90.0)/180.0));
			}
		}
		//cout<<"      "<<distance_ls_p(p[0][4],p[0][1],p[2][2])<<endl;

		
		vector<vector<double> > cost(n,vector<double>(n,INF));
		
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				double a=cal(i,j);
				cost[i][j]=a;
				cost[j][i]=a;
			}
		}
		/*
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				cout<<cost[i][j]<<" ";
			}
			cout<<endl;
		}*/
		
		priority_queue<P,vector<P>,greater<P> > que;
		que.push(P(0,s-1));
		vector<double> d(n,INF);
		d[s-1]=0;
		while(!que.empty()){
			P q=que.top();
			int pos=q.second;
			double dist=q.first;
			que.pop();
			if(pos==g-1){
				printf("%.8lf\n",dist);
				break;
			}
			if(dist>d[pos]){
				continue;
			}
			for(int i=0;i<n;i++){
				
				if(cost[pos][i]==INF){
					continue;
				}
				if(cost[pos][i]+dist<d[i]){
					que.push(P(cost[pos][i]+dist,i));
					d[i]=cost[pos][i]+dist;
				}
				
				
			}
		}
		
	}
	return 0;
}