#include using namespace std; const long long INF = (1LL << 60); /* segment tree (noncommutative monoid-compatible) */ /* References: https://hcpc-hokudai.github.io/archive/structure_segtree_001.pdf https://hackmd.io/@tatyam-prime/rkA5wJMdo https://github.com/atcoder/ac-library/blob/master/atcoder/segtree.hpp */ template struct SegmentTree { int n; vector seg; /* ===== change here ===== */ T op(T a, T b) { return a + b; } T e() { return (T)0; } /* ===== ===== ===== ===== */ SegmentTree(int n): n(n), seg(n * 2, e()) {} T operator[](int i) const { return seg[n + i]; } void update(int i, T x) { i += n; seg[i] = x; while(1 < i) { i >>= 1; seg[i] = op(seg[i << 1 | 0], seg[i << 1 | 1]); } } T prod(int l, int r) { T ansL(e()), ansR=(e()); for(l += n, r += n; l < r; l >>= 1, r >>= 1) { if(l & 1) ansL = op(ansL, seg[l++]); if(r & 1) ansR = op(seg[--r], ansR); } return op(ansL, ansR); } T all_prod() { return prod(0, n); } }; int main() { int N, M, K; cin >> N >> M >> K; vector S(K+1, 0); for(int i = 0; i < K+1; i++) { cin >> S[i]; S[i]--; } vector A(M, 0), B(M, 0); vector C(M, 0LL); vector dist(N, vector(N, INF)); for(int i = 0; i < M; i++) { cin >> A[i] >> B[i] >> C[i]; A[i]--, B[i]--; dist[A[i]][B[i]] = C[i]; dist[B[i]][A[i]] = C[i]; } for(int k = 0; k < N; k++) { for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]); } } } int Q; cin >> Q; vector T(Q, 0), X(Q, 0), Y(Q, 0); for(int i = 0; i < Q; i++) cin >> T[i] >> X[i] >> Y[i]; SegmentTree segtree(K); for(int i = 0; i < K; i++) { segtree.update(i, dist[S[i]][S[i+1]]); } for(int i = 0; i < Q; i++) { if(T[i] == 1) { Y[i]--; S[X[i]] = Y[i]; if(0 <= X[i]-1) segtree.update(X[i]-1, dist[S[X[i]-1]][S[X[i]]]); if(X[i]+1 < K+1) segtree.update(X[i], dist[S[X[i]]][S[X[i]+1]]); } if(T[i] == 2) { long long ans(segtree.prod(X[i], Y[i])); cout << ans << endl; } } return 0; }