#include <bits/stdc++.h>
using namespace std;
typedef double db;
const int N=200;
int n,s,t,A,B,p;
db S(db x){return x*x;}
struct point{
db x,y;
point(){}
point(db _x,db _y){x=_x,y=_y;}
void print(){cout<<x<<" "<<y<<'\n';}
}aa,bb,cc,dd;
point read(){db x,y;cin>>x>>y;return point(x,y);}
point operator +(point a,point b){return point(a.x+b.x,a.y+b.y);}
point operator -(point a,point b){return point(a.x-b.x,a.y-b.y);}
db operator *(point a,point b){return a.x*b.x+a.y*b.y;}
db dis(point a,point b){return sqrt(S(b.x-a.x)+S(b.y-a.y));}
db d[500][500];
point now[500];//存城市坐标
int T[N];
void readr(int i){
aa=read();bb=read();cc=read();
cin>>T[i];
if((bb-aa)*(cc-aa)==0) dd=bb+cc-aa;
if((bb-aa)*(cc-bb)==0) dd=aa+cc-bb;
if((cc-bb)*(cc-aa)==0) dd=aa+bb-cc;//使用向量点乘更简单
now[p++]=aa,now[p++]=bb,now[p++]=cc,now[p++]=dd;
}
void build(){
memset(d,127,sizeof d);
for(int i=0;i<p;i++) d[i][i]=0;
for(int i=0;i<p;i+=4){
d[i+0][i+1]=dis(now[i+0],now[i+1])*T[i/4];
d[i+0][i+2]=dis(now[i+0],now[i+2])*T[i/4];
d[i+0][i+3]=dis(now[i+0],now[i+3])*T[i/4];
d[i+1][i+2]=dis(now[i+1],now[i+2])*T[i/4];
d[i+1][i+3]=dis(now[i+1],now[i+3])*T[i/4];
d[i+2][i+3]=dis(now[i+2],now[i+3])*T[i/4];
}//市内换乘
for(int i=0;i<p;i++)
for(int j=0;j<p;j++){
if(i/4==j/4) continue;
d[i][j]=dis(now[i],now[j])*t;
}//市外换乘
}
db sol(){
for(int k=0;k<p;k++)
for(int i=0;i<p;i++)
for(int j=0;j<p;j++)
if(d[i][j]>d[i][k]+d[k][j])
d[i][j]=d[i][k]+d[k][j];//floyd
db ans=1e9;
for(int i=0;i<4;i++)
for(int j=0;j<4;j++)
ans=min(ans,d[(A-1)*4+i][(B-1)*4+j]);//求解答案
return ans;
}
int main(){
ios::sync_with_stdio(0);
cin>>n;
while(n--){
p=0;
cin>>s>>t>>A>>B;
for(int i=0;i<s;i++) readr(i);
build();//建图
cout<<fixed<<setprecision(1)<<sol()<<'\n';
}
return 0;
}