n,m,k=map(int,input().split()) g = [['-']*n for _ in range(n)] v=[] for _ in range(m): i,j,c=map(int,input().split()) g[i-1][j-1] = c g[j-1][i-1] = c v.append((c,i-1,j-1)) p = list(range(len(g))) s = [1]*len(g) def f(x): if x == p[x]: return x p[x] = f(p[x]) return p[x] def u(x, y): x = f(x) y = f(y) if s[x] > s[y]: x, y = y, x p[x] = p[y] s[y] += s[x] e = {(int(c),i,j) for i,r in enumerate(g) for j,c in enumerate(r) if c != '-'} pp =0 for _ in range(k): c,i,j=v[int(input())-1] e.remove((c,i,j)) e.remove((c,j,i)) e.add((0,i,j)) e.add((0,j,i)) pp += c e = sorted(e) r = 0 d = 0 for c,i,j in e: if f(i)==f(j): r += c continue u(i,j) d += c print((r-d)//2)