#include<stdio.h>
#include<math.h>

int main(){
	int piles,fences,i,j;

	double output = 0.0;

	//読み込み
	scanf("%d %d",&piles,&fences);
	int pilex[piles],piley[piles],fencex[fences],fencey[fences];
	for(j=0;j<piles;j++){
		scanf("%d %d",&pilex[j],&piley[j]);
	}
	for(j=0;j<fences;j++){
		scanf("%d %d",&fencex[j],&fencey[j]);
	}

	while(1){
		//隣接リストを作る
		int nextto[piles][piles-1];
		for(i=0;i<piles;i++){
			for(j=0;j<piles-1;j++){
				nextto[i][j] = -1;
			}
		}
		for(i=0;i<piles;i++){
			int counter=0;
			for(j=0;j<fences;j++){
				if(i+1 == fencex[j]){
					nextto[i][counter] = fencey[j] - 1;
					counter++;
				}else if(i+1 == fencey[j]){
					nextto[i][counter] = fencex[j] - 1;
					counter++;
				}
			}
		}

		//閉路の検出
		int circuit[piles];
		for(i=0;i<piles;i++){
			circuit[i] = -1;
		}

		if(!circuitdetect(piles,nextto,&circuit)){
			break;
		}

		//検出した閉路の中で最小の枝を求める
		double min = 10000000.0;
		double dist = 100000000.0;
		int mfrom = 0;
		int mto = 0;
		int from,to;
		for(i=0;i<piles;i++){
			if(circuit[i] == -1){
				break;
			}
			from = circuit[i];
			if(i == piles-1 || circuit[i+1] == -1){
				to = circuit[0];
			}else{
				to = circuit[i+1];	
			}
			dist = sqrt(pow(pilex[to] - pilex[from],2.0) + pow(piley[to] - piley[from],2.0));

			if(dist  < min){
				min = dist;
				mfrom = from;
				mto = to;
			}
		}

		//最小の枝を狩る
		output += min;
		for(j=0;j<fences;j++){
			if((fencex[j] - 1 == mfrom && fencey[j] - 1 == mto) || (fencex[j] - 1 == mto && fencey[j] - 1 == mfrom)){
				fencex[j] = 0;
				fencey[j] = 0;
				break;
			}
		}


	}

	printf("%f\n",output);

	return 0;
}

int circuitdetect(int peaknum,int nextlist[peaknum][peaknum-1],int* retval){
	int k,l;
	int visited[peaknum];

	for(l=0;l<peaknum;l++){
		visited[l] = 0;
	}

	for(k=0;k<peaknum;k++){

		if(visited[k] == 0){
			retval[0] = k;
			int nest = 0;
			int value = reflex_search(k,peaknum,nextlist,&visited,nest,retval);
			if(value == 1){
				return 1;
			}else{
				for(l=0;l<peaknum;l++){
					retval[l] = -1;
				}
			}
		}

	}

	return 0;
}

int reflex_search(int r_k,int r_p,int r_n[r_p][r_p-1],int* r_v,int r_nest,int* r_rv){
	r_v[r_k] = 1;
	r_nest++;
	int m;
	for(m=0;m<r_p-1;m++){
		if(r_n[r_k][m] != -1){
			if(r_v[r_n[r_k][m]] == 0){
				r_rv[r_nest] = r_n[r_k][m]; 
				if(reflex_search(r_n[r_k][m],r_p,r_n,r_v,r_nest,r_rv)){
					return 1;
				}
			}else if(r_nest > 1 && r_rv[r_nest-2] != r_n[r_k][m]){
				return 1;
			} 
		}
	}

	return 0;
}