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
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define re(i, n) FOR(i, 1, n)
#define ford(i, a, b) for (int i = (a); i >= (b); --i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pll> vpll;
typedef vector<pii> vpii;

const ll inf = 1e18;
const int N = 5005;
const int mod = 1e9 + 7;

set<pll> Adj[N];
int col[N];
ll dd = 0ll;
ll qmax;
int qcol;

struct query
{
    int type;
    ll arg1;
    ll arg2;
    ll arg3;
};

void dfs(int v, int p)
{
    col[v] = qcol;
    for (const pll &up : Adj[v])
    {
        ll d = up.second;
        ll u = up.first;
        if (u != p && up.second + dd <= qmax)
        {
            dd += d;
            dfs(u, v);
            dd -= d;
        }
    }
}

vector<query> qq;
int qdupacnt = 0;
ll minz = inf;
ll dupaconst = 1'000'000'000'000'000ll;
int n, m, q;

void solve_zero_add()
{

}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> q;
    rep(i, m)
    {
        int a, b;
        ll d;
        cin >> a >> b >> d;
        a--;
        b--;
        Adj[a].insert({b, d});
        Adj[b].insert({a, d});
    }
    /*rep(i, q)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int a, b;
            ll d;
            cin >> a >> b >> d;
            qq.push_back({1, a, b, d});
            qdupacnt++;
        }
        else if (t == 2)
        {
            int a, b;
            cin >> a >> b;
            a--;
            b--;
            qq.push_back({2, a, b, 0});
            qdupacnt++;
        }
        else if (t == 3)
        {
            int a;
            cin >> a >> qmax >> qcol;
            qq.push_back({3, a, qmax, qcol});
            minz = min(minz, qmax);
        }
        else
        {
            int a;
            cin >> a;
            qq.push_back({4, a, qmax, qcol});
        }
    }
    if (qdupacnt == 0)
    {
        solve_zero_add();
    }
    else if (minz >= dupaconst)
    {
        solve_full_color();
    }*/
    {
        rep(i, q)
        {
            int t;
            cin >> t;
            if (t == 1)
            {
                int a, b;
                ll d;
                cin >> a >> b >> d;
                a--;
                b--;
                Adj[a].insert({b, d});
                Adj[b].insert({a, d});
            }
            else if (t == 2)
            {
                int a, b;
                cin >> a >> b;
                a--;
                b--;
                auto it = Adj[a].upper_bound({b, -inf});
                Adj[a].erase(it);
                it = Adj[b].upper_bound({a, -inf});
                Adj[b].erase(it);
            }
            else if (t == 3)
            {
                int a;
                cin >> a >> qmax >> qcol;
                a--;
                dfs(a, -1);
            }
            else
            {
                int a;
                cin >> a;
                cout << col[a - 1] << '\n';
            }
        }
    }
}