1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <bits/stdc++.h>
using namespace std;
const int MX=200100,ME=MX*2;
const long long INF=10000000000000000LL;
int n,m,q,col,c[MX],x[ME],y[ME];
vector<int> g[MX];
long long d[ME];
map<pair<int,int>,int> w;
void dfs(int i, int p, long long dst) {
  c[i]=col;
  for (int ed: g[i]) if (ed!=p && dst>=d[ed]) dfs((x[ed]^y[ed]^i),ed,dst-d[ed]);
}
int main() {
  scanf("%d%d%d",&n,&m,&q);
  for (int i=0; i<m; i++) {
    scanf("%d%d%lld",&x[i],&y[i],&d[i]);
    if (x[i]>y[i]) swap(x[i],y[i]);
    g[x[i]].push_back(i);
    g[y[i]].push_back(i);
    w[{x[i],y[i]}]=i;
  }
  while (q--) {
    int tp,X;
    scanf("%d%d",&tp,&X);
    if (tp==1) {
      x[m]=X;
      scanf("%d%lld",&y[m],&d[m]);
      if (x[m]>y[m]) swap(x[m],y[m]);
      g[x[m]].push_back(m);
      g[y[m]].push_back(m);
      w[{x[m],y[m]}]=m;
      m++;
    } else if (tp==2) {
      int Y;
      scanf("%d",&Y);
      if (X>Y) swap(X,Y);
      auto it=w.find({X,Y});
      d[it->second]=INF;
    } else if (tp==3) {
      long long dst;
      scanf("%lld%d",&dst,&col);
      dfs(X,-1,dst);
    } else printf("%d\n",c[X]);
  }
  return 0;
}