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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 2137
#endif

const int N = 200200;
int n, m, q;
int a[N];
map<pair<int, int>, int> c;
set<pair<int, int>> adj[N];

void dod(int u, int v, int d) {
  if (u > v) {
    swap(u, v);
  }
  adj[u].insert({v, d});
  adj[v].insert({u, d});
  c[{u, v}] = d;
}

void dfs(int u, int p, ll d, int k) {
  a[u] = k;
  for (auto [v, w] : adj[u]) {
    if (v != p && d - w >= 0) {
      dfs(v, u, d - w, k);
    }
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> q;
  for (int i = 0; i < m; i++) {
    int u, v, d;
    cin >> u >> v >> d;
    u--; v--;
    dod(u, v, d);
  }
  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int u, v, d;
      cin >> u >> v >> d;
      u--; v--;
      dod(u, v, d);
    } else if (t == 2) {
      int u, v;
      cin >> u >> v;
      u--; v--;
      if (u > v) {
        swap(u, v);
      }
      int d = c[{u, v}];
      adj[u].erase({v, d});
      adj[v].erase({u, d});
    } else if (t == 3) {
      int u, k;
      ll d;
      cin >> u >> d >> k;
      u--;
      dfs(u, -1, d, k);
    } else {
      int u;
      cin >> u;
      cout << a[u - 1] << '\n';
    }
  }
}