#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int n,m; cin>>n>>m; vector x(n*2),y(n*2);//,z(n),w(n); rep(i,n*2){ cin>>x[i]>>y[i]; } vector d(n*2,vector(n*2,1e18)); rep(i,n*2){ rep(j,n*2){ if(i==j)d[i][j] = 0.0; bool f = false; if(i%2==0 && i+1==j)f = true; else{ f = true; rep(k,n){ if(k==i/2 || k==j/2)continue; long long t = 1; long long dx0 = x[j]-x[i],dy0 = y[j]-y[i]; long long dx1 = x[k*2]-x[j], dy1 = y[k*2]-y[j]; t *= dx0*dy1 - dx1*dy0; dx1 = x[k*2+1]-x[j], dy1 = y[k*2+1]-y[j]; t *= dx0*dy1 - dx1*dy0; if(t<0){ dx0 = x[k*2]-x[k*2+1],dy0 = y[k*2]-y[k*2+1]; dx1 = x[k*2+1]-x[i], dy1 = y[k*2+1]-y[i]; t = 1; t *= dx0*dy1 - dx1*dy0; dx1 = x[k*2+1]-x[j], dy1 = y[k*2+1]-y[j]; t *= dx0*dy1 - dx1*dy0; if(t<0){ f = false; break; } } } if(f){ d[i][j] = hypot(x[j]-x[i],y[j]-y[i]); } } } } rep(i,n*2){ rep(j,n*2){ rep(k,n*2){ d[j][k] = min(d[j][k],d[j][i] + d[i][k]); } } } rep(_,m){ int a,b,c,D; cin>>a>>b>>c>>D; a--,b--,c--,D--; cout<