public static int shortestWeightedDistance(int[][]G, int i, int j) {
		int n=G.length;
		int[]d=new int[n];
		Arrays.fill(d,Integer.MAX_VALUE/2);
		Queue<int[]>q=new PriorityQueue<>((a,b)->a[1]-b[1]);
		q.offer(new int[]{1,d[i]=0});
		while (!q.isEmpty()) {
			int x=q.poll()[0];
			for (int k=0;k<n;++k) {
				if (G[x][k]!=-1&&d[x]+G[x][k]<d[k]) {
					d[k]=d[x]+G[x][k];
					q.offer(new int[]{k,d[k]});
				}
			}
		}
		return d[j];
	}