class BinaryIndexedTree(): def __init__(self,default=0): self.size=0 if type(default)==int: self.size=default else: self.size=len(default) self.bit=[0 for i in range(self.size+1)] self.stan=[0 for i in range(self.size)] if type(default)!=int: for i,j in enumerate(default): self[i]=j def __setitem__(self,pos,val): add=val-self.stan[pos] self.stan[pos]=val pos+=1 while pos<=self.size: self.bit[pos]+=add pos+=pos&(-pos) def __getitem__(self,pos): if type(pos)==int: return self.stan[pos] else: left=pos.start if left==None: left=0 right=pos.stop if right==None: right=self.size return self._sum0(right-1)-self._sum0(left-1) def _sum0(self,right): pos=right+1 ret=0 while pos>0: ret+=self.bit[pos] pos-=pos&(-pos) return ret import sys #sys.setrecursionlimit((1<<19)-1) #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') input=sys.stdin.buffer.readline INF=1<<60 N,M,K=map(int,input().split()) K+=2 S=list(map(int,input().split()))+[1] di=[[INF]*N for i in range(N)] for i in range(N): di[i][i]=0 for i in range(M): A,B,C=map(int,input().split()) di[A-1][B-1]=C di[B-1][A-1]=C for i in range(N): for j in range(N): for k in range(N): di[j][k]=min(di[j][k],di[j][i]+di[i][k]) st=[0]*K S[0]-=1 for i in range(K-1): S[i+1]-=1 st[i+1]=di[S[i]][S[i+1]] bit=BinaryIndexedTree(st) Q=int(input()) for i in range(Q): T,X,Y=map(int,input().split()) if T==1: Y-=1 S[X]=Y if X!=0: bit[X]=di[S[X-1]][Y] bit[X+1]=di[Y][S[X+1]] else: print(bit[X+1:Y+1])