#define rep(i,n) for(int i=0;i<(int)(n);i++) #include using namespace std; const int MA=310,MB=2e5+7,INF=1e9+7; double EPS=1e-9,dis[MA][MA],X[MA],Y[MA]; int n,m,A[MB],B[MB],C[MB],D[MB]; 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) cin>>A[i]>>B[i]>>C[i]>>D[i]; 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)->bool{ if(cr(a,b,c)*cr(a,b,d)<0 && cr(c,d,a)*cr(c,d,b)<0) return false; return 1; }; rep(i,2*n){ for(int j=i+1;j<2*n;j++){ bool 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]-1)+B[i]-1][2*(C[i]-1)+D[i]-1]); return 0; }