#include #ifdef LOCAL #include "./debug.cpp" #else #define debug(...) #define print_line #endif using namespace std; using ll = long long; // #include "kyopro_library/data_structure/fen.cpp" #include using namespace atcoder; int main() { int N, M, K; cin >> N >> M >> K; vector S(K + 1); for (int i = 0; i <= K; i++) cin >> S[i], S[i]--; vector> G(N, vector(N, INT_MIN)); for (int i = 0; i < M; i++) { int u, v, w; cin >> u >> v >> w; u--; v--; G[u][v] = G[v][u] = w; } for (int i = 0; i < N; i++) G[i][i] = 0; for (int k = 0; k < N; k++) { for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (G[i][k] != INT_MIN && G[k][j] != INT_MIN) { G[i][j] = min(G[i][j], G[i][k] + G[k][j]); } } } } fenwick_tree fw(K); for (int i = 0; i < K; i++) fw.add(i, G[S[i]][S[i + 1]]); int Q; cin >> Q; while (Q--) { int t, x, y; cin >> t >> x >> y; if (t == 1) { y--; if (x > 0) { fw.add(x - 1, -G[S[x - 1]][S[x]]); fw.add(x - 1, G[S[x - 1]][y]); } if (x < K) { fw.add(x, -G[S[x]][S[x + 1]]); fw.add(x, G[y][S[x + 1]]); } S[x] = y; } else { if (x == y) { cout << 0 << '\n'; } else { cout << fw.sum(x, y) << '\n'; } } debug(fw); } }