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

using namespace std;

const int N = 2e5 + 5;

class edge{
public:
	int v, w;
	inline edge() {}
	inline edge(int v0, int w0){
		v = v0, w = w0;
	}
};

inline bool operator == (edge a, edge b){
	return a.v == b.v;
}

int n = 0, m = 0, q = 0, col[N] = {};
vector<edge> G[N] = {};

inline void dfs(int u, long long d, int c, int p = 0){
	col[u] = c;
	for(edge e : G[u]){
		int v = e.v, w = e.w;
		if(v != p && w <= d) dfs(v, d - w, c, u);
	}
}

int main(){
	scanf("%d %d %d", &n, &m, &q);
	for(int i = 1, u = 0, v = 0, w = 0 ; i <= m ; i ++){
		scanf("%d %d %d", &u, &v, &w);
		G[u].push_back(edge(v, w)), G[v].push_back(edge(u, w));
	}
	for(int i = 1, p = 0 ; i <= q ; i ++){
		scanf("%d", &p);
		if(p == 1){
			int u = 0, v = 0, w = 0;
			scanf("%d %d %d", &u, &v, &w);
			G[u].push_back(edge(v, w)), G[v].push_back(edge(u, w));
		}
		else if(p == 2){
			int u = 0, v = 0;
			scanf("%d %d", &u, &v);
			G[u].erase(find(G[u].begin(), G[u].end(), edge(v, 0))), G[v].erase(find(G[v].begin(), G[v].end(), edge(u, 0)));
		}
		else if(p == 3){
			int u = 0, c = 0;
			long long d = 0;
			scanf("%d %lld %d", &u, &d, &c);
			dfs(u, d, c);
		}
		else if(p == 4){
			int u = 0;
			scanf("%d", &u);
			printf("%d\n", col[u]);
		}
	}
	return 0;
}