#include using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; template struct WarshallFloyd { std::vector> graph, dist; WarshallFloyd(const std::vector>& graph, const T inf) : graph(graph), dist(graph), inf(inf), n(graph.size()), internal(n, std::vector(n, -1)) { for (int k = 0; k < n; ++k) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (dist[i][k] + dist[k][j] < dist[i][j]) { dist[i][j] = dist[i][k] + dist[k][j]; internal[i][j] = k; } } } } } void add(const int src, const int dst, const T cost) { srcs.emplace_back(src); dsts.emplace_back(dst); costs.emplace_back(cost); } void calc() { const int m = srcs.size(); for (int i = 0; i < m; ++i) { graph[srcs[i]][dsts[i]] = std::min(graph[srcs[i]][dsts[i]], costs[i]); if (costs[i] <= dist[srcs[i]][dsts[i]]) { dist[srcs[i]][dsts[i]] = costs[i]; internal[srcs[i]][dsts[i]] = -1; } } std::vector vers(m * 2); std::copy(srcs.begin(), srcs.end(), vers.begin()); std::copy(dsts.begin(), dsts.end(), std::next(vers.begin(), m)); std::sort(vers.begin(), vers.end()); vers.erase(std::unique(vers.begin(), vers.end()), vers.end()); for (const int ver : vers) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (dist[i][j] > dist[i][ver] + dist[ver][j]) { dist[i][j] = dist[i][ver] + dist[ver][j]; internal[i][j] = ver; } } } } srcs.clear(); dsts.clear(); costs.clear(); } bool has_negative_cycle() const { for (int i = 0; i < n; ++i) { if (dist[i][i] < 0) return true; } return false; } std::vector build_path(const int s, const int t) const { std::vector res; if (dist[s][t] != inf) { build_path(s, t, &res); res.emplace_back(t); } return res; } private: const T inf; const int n; std::vector srcs, dsts; std::vector costs; std::vector> internal; void build_path(const int s, const int t, std::vector* path) const { const int k = internal[s][t]; if (k == -1) { (*path).emplace_back(s); } else { build_path(s, k, path); build_path(k, t, path); } } }; template struct FenwickTree { explicit FenwickTree(const int n, const Abelian ID = 0) : n(n), ID(ID), data(n, ID) {} void add(int idx, const Abelian val) { for (; idx < n; idx |= idx + 1) { data[idx] += val; } } Abelian sum(int idx) const { Abelian res = ID; for (--idx; idx >= 0; idx = (idx & (idx + 1)) - 1) { res += data[idx]; } return res; } Abelian sum(const int left, const int right) const { return left < right ? sum(right) - sum(left) : ID; } Abelian operator[](const int idx) const { return sum(idx, idx + 1); } int lower_bound(Abelian val) const { if (val <= ID) [[unlikely]] return 0; int res = 0; for (int mask = std::bit_ceil(static_cast(n + 1)) >> 1; mask > 0; mask >>= 1) { const int idx = res + mask - 1; if (idx < n && data[idx] < val) { val -= data[idx]; res += mask; } } return res; } private: const int n; const Abelian ID; std::vector data; }; int main() { int n, m, k; cin >> n >> m >> k; vector s(k + 1); for (int& s_i : s) cin >> s_i, --s_i; vector graph(n, vector(n, LINF)); REP(i, n) graph[i][i] = 0; while (m--) { int a, b, c; cin >> a >> b >> c; --a; --b; graph[a][b] = graph[b][a] = c; } const WarshallFloyd wf(graph, LINF); FenwickTree bit(k + 1); FOR(i, 1, k + 1) bit.add(i, wf.dist[s[i - 1]][s[i]]); int q; cin >> q; while (q--) { int t, x, y; cin >> t >> x >> y; if (t == 1) { --y; s[x] = y; if (x > 0) { bit.add(x, -bit[x]); bit.add(x, wf.dist[s[x - 1]][s[x]]); } if (x + 1 < k) { bit.add(x + 1, -bit[x + 1]); bit.add(x + 1, wf.dist[s[x]][s[x + 1]]); } } else if (t == 2) { cout << bit.sum(x + 1, y + 1) << '\n'; } } return 0; }