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
#include <bits/stdc++.h>

#define ll long long
#define fors(u, n, s) for(ll u = (s); u < (n); u++)
#define foru(u, n) fors(u, n, 0)
#define vec vector
#define pb push_back
#define f first
#define s second
#define ir(a, b, x) (((a) <= (x)) && ((x) <= (b)))
#define pint pair<int, int>
#define us unsigned

using namespace std;

const int N = 3e5;
int n;

map<int, ll> edges[N];
int color[N];

void paint(int idx, ll dist, int c, int parent) {
	color[idx]=c;
	for(auto i : edges[idx]){
		if(i.f == parent) continue;
		if(i.s > dist) continue;
		paint(i.f, dist - i.s, c, idx);
	}
}

int main(){
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);

	int m, q; cin >> n >> m >> q;

	foru(_i, m){
		int a, b; ll d; cin >> a >> b >> d; a--; b--;
		edges[a][b]=d; edges[b][a]=d;
	}
	
	foru(_i, q) {
		int c; cin >> c;
		if (c == 1){
			int a, b; ll d; cin >> a >> b >> d; a--; b--;
			edges[a][b]=d; edges[b][a]=d;	
		} else if (c == 2){
			int a; int b; cin >> a >> b; a--; b--;
			edges[a].erase(b); edges[b].erase(a);
		} else if (c == 3) {
			int a; ll d; int c; cin >> a >> d >> c; a--;
			paint(a, d, c, -1);
		} else if (c == 4) {
			int a; cin >> a; a--;
			cout << color[a] << endl;
		}
	}

}