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
76
#include <cstdio>
#include <map>
#include <vector>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define VAR(v,w) __typeof(w) v=(w)
#define FORE(it,c) for(VAR(it,(c).begin());it!=(c).end();++it)
#define FT first
#define SD second
#define INT(x) int x; scanf("%d", &x)
#define LLG(x) LL x; scanf("%lld", &x)

typedef long long LL;

vector<map<int, int> > g;
int ko[200000];

void go(int v, LL z, int k) {
	if (z < 0) return;
	ko[v] = k;
	FORE(it,g[v]) go(it->FT, z - it->SD, k);
}

int main() {
	INT(n);
	INT(m);
	INT(q);
	g.resize(n);
	REP(j,m) {
		INT(a);
		INT(b);
		INT(d);
		--a;
		--b;
		g[a][b] = g[b][a] = d;
	}
	REP(qq,q) {
		INT(t);
		switch (t) {
			case 1: {
				INT(a);
				INT(b);
				INT(d);
				--a;
				--b;
				g[a][b] = g[b][a] = d;
				break;
			}
			case 2: {
				INT(a);
				INT(b);
				--a;
				--b;
				g[a].erase(b);
				g[b].erase(a);
				break;
			}
			case 3: {
				INT(v);
				LLG(z);
				INT(k);
				--v;
				go(v, z, k);
				break;
			}
			case 4: {
				INT(u);
				--u;
				printf("%d\n", ko[u]);
				break;
			}
		}
	}
}