#define rep(i,n) for(int i=0;i<(int)(n);i++) #include using namespace std; double EPS=1e-9,dis[310][310],X[310],Y[310]; int n,m,A[200200][4],INF=1e9+7; void floyd(){ rep(k,2*n){ rep(i,2*n){ if(dis[i][k]>INF-EPS) continue; rep(j,2*n){ if(dis[k][j]>INF-EPS) continue; dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]); } } } } int main(){ cin>>n>>m; rep(i,2*n){ rep(j,2*n) if(i!=j) dis[i][j]=INF; cin>>X[i]>>Y[i]; } rep(i,m) rep(j,4) cin>>A[i][j]; auto cr=[&](int a,int b,int c)->double{ return (X[b]-X[a])*(Y[c]-Y[a])-(Y[b]-Y[a])*(X[c]-X[a]); }; auto f=[&](int a,int b,int c,int d)->int{ return (cr(a,b,c)*cr(a,b,d)<0 && cr(c,d,a)*cr(c,d,b)<0)?0:1; }; rep(i,2*n){ for(int j=i+1;j<2*n;j++){ int e=1; rep(k,n){ if(k==i/2 || k==j/2) continue; if(f(i,j,2*k,2*k+1)==0) e=0; } if(e){ double p=X[i]-X[j],q=Y[i]-Y[j]; dis[j][i]=dis[i][j]=sqrt(p*p+q*q); } } } floyd(); rep(i,m) printf("%.10f\n",dis[2*A[i][0]+A[i][1]-3][2*A[i][2]+A[i][3]-3]); return 0; }