import std.conv, std.functional, std.range, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } string COLOR(string s = "") { return "\x1b[" ~ s ~ "m"; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } enum INF = 10L^^18; void bAdd(T)(T[] bit, int pos, T val) in { assert(0 <= pos && pos < bit.length, "bAdd: 0 <= pos < |bit| must hold"); } do { for (int x = pos; x < bit.length; x |= x + 1) { bit[x] += val; } } // sum of [0, pos) T bSum(T)(T[] bit, int pos) in { assert(0 <= pos && pos <= bit.length, "bSum: 0 <= pos <= |bit| must hold"); } do { T ret = 0; for (int x = pos - 1; x >= 0; x = (x & (x + 1)) - 1) { ret += bit[x]; } return ret; } void main() { try { for (; ; ) { const N = readInt; const M = readInt; const K = readInt; auto S = new int[K + 1]; foreach (k; 0 .. K + 1) { S[k] = readInt - 1; } auto A = new int[M]; auto B = new int[M]; auto C = new long[M]; foreach (i; 0 .. M) { A[i] = readInt - 1; B[i] = readInt - 1; C[i] = readInt; } auto d = new long[][](N, N); foreach (u; 0 .. N) { d[u][] = INF; d[u][u] = 0; } foreach (i; 0 .. M) { chmin(d[A[i]][B[i]], C[i]); chmin(d[B[i]][A[i]], C[i]); } foreach (w; 0 .. N) foreach (u; 0 .. N) foreach (v; 0 .. N) { chmin(d[u][v], d[u][w] + d[w][v]); } auto us = S.dup; auto fs = new long[K]; foreach (k; 0 .. K) { fs[k] = d[us[k]][us[k + 1]]; } auto bit = fs.dup; foreach (k; 0 .. K) { const kk = k | k + 1; if (kk < K) bit[kk] += bit[k]; } const Q = readInt; foreach (q; 0 .. Q) { const T = readInt; if (T == 1) { const X = readInt; const U = readInt - 1; us[X] = U; foreach (k; [X - 1, X]) if (0 <= k && k <= X) { const ff = d[us[k]][us[k + 1]]; bit.bAdd(k, ff - fs[k]); fs[k] = ff; } } else if (T == 2) { const L = readInt; const R = readInt; const ans = bit.bSum(R) - bit.bSum(L); writeln(ans); } else { assert(false); } } } } catch (EOFException e) { } }