Problem: Problem

Chocolate company Chinor Choco has decided to build n new stores.
For each store, ask each store manager to prepare two candidates for the place you want to build, and build it in either place.

Chinor Choco sells m types of chocolate, each manufactured at a different factory.
All types of chocolate are sold at all stores.
Chinor Choco owns only one truck to transport chocolate, and one truck can only carry one store's worth of chocolate.
Therefore, trucks need to go around all factories when moving from one store to another.

Find the maximum travel distance when the stores are arranged so that the maximum minimum travel distance when moving from one store to another is the minimum.

There can be multiple stores and factories in the same location.

Constraints

The input satisfies the following conditions.

* 2 ≤ n ≤ 200
* 1 ≤ m ≤ 15
* 0 ≤ ai, bi, ci, di, xi, yi ≤ 1000

Input

The input is given in the following format.


n m
a0 b0 c0 d0
...
an−1 bn−1 cn−1 dn−1
x0 y0
...
xm−1 ym−1


All inputs are given as integers.
On the first line, the number of Chinor chocolate shops n and the number of chocolate manufacturing factories m are given, separated by blanks.
From the second line to the nth line, the coordinates (ai, bi), (ci, di) of the candidate places to build each store are given separated by blanks.
2 & plus; Factory coordinates (xi, yi) are given from the nth line to the mth line, separated by blanks.

Output

Output the maximum travel distance when the store is arranged so that the maximum of the minimum travel distance is minimized.
The error should not exceed 10-6.

Examples

Input

2 1
0 0 5 5
3 3 6 6
2 2


Output

4.2426406871


Input

2 2
0 0 6 0
7 0 3 0
4 0
5 0


Output

3.0000000000

Solution (in CPP):

Solution:

#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

typedef complex<double>Point;

int N,M;
Point A[222][2];

const double INF=1e18;
double dp[15][15][1<<15];
Point P[15];


namespace SCC{
    void visit(const vector<vector<int>>&G,vector<int>&vs,vector<int>&used,int v){
        used[v]=true;
        for(auto u:G[v]){
            if(!used[u])visit(G,vs,used,u);
        }
        vs.push_back(v);
    }

    void visit2(const vector<vector<int>>&T,vector<int>&used,vector<int>&comp,vector<int>&vec,int k,int v){
        comp[v]=k;
        used[v]=true;
        vec.push_back(v);

        for(auto u:T[v]){
            if(!used[u])visit2(T,used,comp,vec,k,u);
        }
    }

   void decompose(const vector<vector<int>>&G,vector<vector<int>>&H,vector<int>&comp){
        vector<vector<int>>T(G.size());
        for(int i=0;i<G.size();i++){
            for(auto v:G[i]){
                T[v].push_back(i);
            }
        }
        comp.resize(G.size());

        vector<int>vs(G.size());
        vector<int>used(G.size());
        for(int i=0;i<G.size();i++){
            if(!used[i])visit(G,vs,used,i);
        }
        reverse(vs.begin(),vs.end());
        fill(used.begin(),used.end(),0);

        int K=0;
        vector<vector<int>>S;
        for(auto v:vs){
            if(!used[v]){
                S.push_back(vector<int>());
                visit2(T,used,comp,S.back(),K++,v);
            }
        }

        H.resize(K);
        fill(used.begin(),used.end(),0);
        for(int i=0;i<K;i++){
            for(auto v:S[i]){
                for(auto u:G[v]){
                    if(used[comp[u]]||comp[v]==comp[u])continue;
                    used[comp[u]]=true;
                    H[comp[v]].push_back(comp[u]);
                }
            }
            for(auto v:H[i])used[v]=false;
        }

    }
}


double dist[200][2][200][2];

bool C(double d){
    vector<vint> G(2*N);
    rep(i,N){
        rep(j,N){
            if(i==j)continue;
            rep(k,2){
                rep(l,2){
                    if(dist[i][k][j][l]>d)G[i*2+k].pb(j*2+1-l),G[j*2+l].pb(i*2+1-k);
                }
            }
        }
    }

    vector<vint>H;
    vint comp;
    SCC::decompose(G,H,comp);

    rep(i,N)if(comp[i*2]==comp[i*2+1])return false;
    return true;
}

signed main(){
    cin>>N>>M;
    rep(i,N){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        A[i][0]=Point(a,b);
        A[i][1]=Point(c,d);
    }


    rep(i,M){
        int a,b;
        cin>>a>>b;
        P[i]=Point(a,b);
    }

    fill_n(**dp,15*15*(1<<15),INF);

    rep(s,M){
        dp[s][s][1<<s]=0;

        rep(b,1<<M){
            rep(v,M){
                rep(u,M){
                    if(b>>u&1)continue;
                    chmin(dp[s][u][b|(1<<u)],dp[s][v][b]+abs(P[v]-P[u]));
                }
            }
        }
    }

    rep(i,N){
        rep(j,N){
            rep(k,2){
                rep(l,2){
                    double mi=INF;
                    rep(v,M)rep(u,M)chmin(mi,abs(P[v]-A[i][k])+dp[v][u][(1<<M)-1]+abs(A[j][l]-P[u]));
                    dist[i][k][j][l]=mi;
                }
            }
        }
    }


    double lb=0.0,ub=1e6;
    rep(i,50){
        double mid=(ub+lb)/2;
        if(C(mid))ub=mid;
        else lb=mid;
    }

    printf("%.20f\n",ub);
    return 0;

}