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<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

struct StronglyConnectedComponents{
    vector<int> used,cmp,vs;
    vector<vector<int>> v,rv;
    StronglyConnectedComponents(int n):used(n),cmp(n,-1),v(n),rv(n){}

    void add_edge(int x,int y){
        v[x].push_back(y);
        rv[y].push_back(x);
    }
    void dfs(int x){
        used[x]=true;
        for(auto to:v[x])if(!used[to])dfs(to);
        vs.push_back(x);
    }

    void rdfs(int x,int k){
        cmp[x]=k;
        for(auto to:rv[x])if(cmp[to]==-1)rdfs(to,k);
    }

    int scc(){
        rep(i,used.size())if(!used[i])dfs(i);
        reverse(vs.begin(),vs.end());
        int k=0;
        for(auto x:vs)if(cmp[x]==-1)rdfs(x,k++);
        return k;
    }
    void build(vector<vector<int>> &g){
        int k=scc();
        g.resize(k);
        set<pair<int,int>> used;
        rep(i,v.size()){
            for(auto& to:v[i]){
                int x=cmp[i],y=cmp[to];
                if(x==y||used.count({x,y}))continue;
                g[x].push_back(y);
                used.emplace(x,y);
            }
        }
    }
};

using Point  =complex<double>;
int main(){
    int n,m;
    cin>>n>>m;
    Point p[n][2];
    rep(i,n)rep(j,2){
        int x,y;
        cin>>x>>y;
        p[i][j]=Point(x,y);
    }
    Point f[m];
    rep(i,m){
        int x,y;
        cin>>x>>y;
        f[i]=Point(x,y);
    }
    double dist[m][m][1<<m];
    rep(i,m){
        rep(j,m)rep(k,1<<m)dist[i][j][k]=inf;
        dist[i][i][1<<i]=0;
        rep(j,1<<m){
            if((j&(1<<i))==0)continue;
            rep(k,m){
                if(((1<<k)&j)==0)continue;
                rep(l,m){
                    //if(k==l||k==i||l==i)continue;
                    if(((1<<l)&j)==0)continue;
                    dist[i][k][j]=min(dist[i][k][j],dist[i][l][j-(1<<k)]+abs(f[k]-f[l]));

                }
            }
        }
    }
    double d[n][n][2][2];
    rep(i,n)rep(j,n)rep(k,2)rep(l,2)d[i][j][k][l]=inf;
    rep(i,n)rep(j,n)rep(k,2)rep(l,2){
        if(i==j)continue;
        rep(x,m)rep(y,m){
            d[i][j][k][l]=min(d[i][j][k][l],abs(f[x]-p[i][k])+dist[x][y][(1<<m)-1]+abs(f[y]-p[j][l]));
        }
    }
    double ok=inf, ng=0;
    rep(_,60){
        double mid = (ok+ng)/2;
        StronglyConnectedComponents scc(2*n);
        rep(i,n)rep(j,n){
            if(i==j)continue;
            if(d[i][j][0][0]>mid){
                scc.add_edge(2*i, 2*j+1);
            }
            if(d[i][j][0][1]>mid){
                scc.add_edge(2*i, 2*j);
            }
            if(d[i][j][1][0]>mid){
                scc.add_edge(2*i+1, 2*j+1);
            }
            if(d[i][j][1][1]>mid){
                scc.add_edge(2*i+1, 2*j);
            }
            
        }
        scc.scc();
        bool can=true;
        rep(i,n){
            if(scc.cmp[2*i]==scc.cmp[2*i+1])can=false;
        }
        if(can)ok=mid;
        else ng=mid;
    }
    cout<<fixed<<setprecision(12)<<ok<<endl;
    return 0;
}