from sys import stdin from itertools import combinations n, m, buildnum, *indata = map(int, stdin.read().split()) a = [] for i in range(n): a.append(indata[i]) offset = n infty = 10**18 dist = [[infty for i in range(n)] for j in range(n)] for i in range(m): s, t, d = indata[offset + 3*i],indata[offset + 3*i+1],indata[offset + 3*i+2] dist[s-1][t-1] = d dist[t-1][s-1] = d for i in range(n): for j in range(n): for k in range(n): dist[j][k] = min(dist[j][i]+dist[i][k], dist[j][k]) dp = [infty for i in range(1<