from typing import Callable, Generic, TypeVar, List T = TypeVar("T") class SegmentTree(Generic[T]): def __init__(self, op:Callable[[T, T], T], e:Callable[[], T], N:int): self._length = 1 while self._length < N: self._length <<= 1 self._tree: List[T] = [e()] * (self._length * 2) self._op = op self._e = e def __getitem__(self, key): return self._tree[key + self._length] def set(self, key:int, val:T): key += self._length self._tree[key] = val key >>= 1 while key: self.update(key) key >>= 1 def update(self, key:int): self._tree[key] = self._op(self._tree[2*key], self._tree[2*key + 1]) def prod(self, l:int, r:int) -> T: l += self._length r += self._length sml, smr = self._e(), self._e() while l < r: if l & 1 : sml = self._op(sml, self._tree[l]); l += 1 if r & 1 : r -= 1; smr = self._op(self._tree[r], smr) l >>= 1; r >>= 1 return self._op(sml, smr) N, M, K = map(int, input().split()) S = list(map(int, input().split())) for i in range(K + 1): S[i] -= 1 dist = [[1<<60 for _ in range(N)] for _ in range(N)] for i in range(N):dist[i][i] = 0 for _ in range(M): a, b, c = map(int, input().split()) dist[a-1][b-1] = c dist[b-1][a-1] = c 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]) def op(x:int, y:int): return x + y def e(): return 0 seg = SegmentTree(op, e, K + 1) for i in range(K): seg.set(i, dist[S[i]][S[i+1]]) Q = int(input()) while Q: Q -= 1 t, x, y = map(int, input().split()) y -= 1 if t == 1: S[x] = y if x > 0 : seg.set(x-1, dist[y][S[x-1]]) if x < K : seg.set(x, dist[y][S[x+1]]) else: print(seg.prod(x, y+1))