#include #include #include #include using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} template struct segment_tree { using T = typename M::T; public: explicit segment_tree(int N) : segment_tree(std::vector(N, M::e())) {} explicit segment_tree(const std::vector& v) { int N = (int)v.size(); n = N; size = 1; while (size < N) size <<= 1; data.resize(2 * size, M::e()); for (int i = 0; i < N; i++) data[size + i] = v[i]; for (int i = size - 1; i >= 1; i--) update(i); }; void set(int p, T x) { assert(0 <= p && p < n); p += size; data[p] = x; while (p > 1) { p >>= 1; update(p); } } T get(int p) { assert(0 <= p && p < n); p += size; return data[p]; } T prod(int l, int r) { assert(0 <= l && l <= r && r <= n); T vl = M::e(), vr = M::e(); l += size; r += size; while (l < r) { if (l & 1) vl = M::op(vl, data[l++]); if (r & 1) vr = M::op(data[--r], vr); l >>= 1; r >>= 1; } return M::op(vl, vr); } T all_prod() { return data[1]; } private: int n, size; std::vector data; void update(int p) { data[p] = M::op(data[2 * p], data[2 * p + 1]); } }; struct Monoid{ using T=ll; static T op(T l,T r){return l+r;} static T e(){return 0;} }; const ll INF=1LL<<60; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,M,K; cin>>N>>M>>K; vectorS(K+1); for(int i=0;i>S[i]; S[i]--; } vector D(N,vector(N,INF)); for(int i=0;i>a>>b>>c; a--; b--; D[a][b]=c; D[b][a]=c; } for(int k=0;kseg(K); for(int i=0;i>Q; while(Q--){ int t,x,y; cin>>t>>x>>y; if(t==1){ y--; S[x]=y; if(x>0)seg.set(x-1,D[S[x-1]][S[x]]); if(x+1<=K)seg.set(x,D[S[x]][S[x+1]]); }else{ cout<