import math N, M, K = map(int, input().split()) S = list(map(int, input().split())) dist = [[10**18] * N for _ in range(N)] for i in range(N): dist[i][i] = 0 for _ in range(M): u, v, w = map(int, input().split()) dist[u - 1][v - 1] = w dist[v - 1][u - 1] = w for k in range(N): for i in range(N): for j in range(N): dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) P = int(math.sqrt(K)) baby = [0] * K giant = [0] * ((K + P - 1) // P) for i in range(K): baby[i] = dist[S[i] - 1][S[i + 1] - 1] giant[i // P] += baby[i] Q = int(input()) for _ in range(Q): T, X, Y = map(int, input().split()) if T == 1: S[X] = Y if X > 0: giant[(X - 1) // P] -= baby[X - 1] baby[X - 1] = dist[S[X - 1] - 1][S[X] - 1] giant[(X - 1) // P] += baby[X - 1] if X < K: giant[X // P] -= baby[X] baby[X] = dist[S[X] - 1][S[X + 1] - 1] giant[X // P] += baby[X] else: ans = 0 x = (X + P - 1) // P y = Y // P if x >= y: for i in range(X, Y): ans += baby[i] print(ans) continue for i in range(x, y): ans += giant[i] for i in range(X, min(K, x * P)): ans += baby[i] for i in range(y * P, Y): ans += baby[i] print(ans)