static double prim(double d[][]){
		PriorityQueue<double[]> cola=new PriorityQueue<double[]>(d.length,new Comparator<double[]>() {
			public int compare(double[] o1, double[] o2) {
				if(o1[1]!=o2[1])return o1[1]<o2[1]?-1:1;
				return o1[0]<o2[0]?-1:1;
			}
		});
		boolean vis[]=new boolean[d.length];
		double mem[]=new double[d.length];
		Arrays.fill(mem,POSITIVE_INFINITY);
		mem[0]=0;cola.add(new double[]{0,0});
		for(;!cola.isEmpty();){
			int v=(int)cola.poll()[0];
			vis[v]=true;
			for(int u=0;u<d.length;u++)
				if(!vis[u]&&mem[u]>d[v][u])cola.add(new double[]{u,mem[u]=d[v][u]});
		}
		double res=0;
		for(int i=0;i<d.length;i++)res+=mem[i];
		return res;
	}