1 #include<cstdio>
2
3 #include<cstdlib>
4
5 #include<cmath>
6
7 #include<cstring>
8
9 #include<algorithm>
10
11 #include<iostream>
12
13 #include<vector>
14
15 #include<map>
16
17 #include<set>
18
19 #include<queue>
20
21 #include<string>
22
23 #define inf 1000000000
24
25 #define maxn 1500000+5
26
27 #define maxm 200000+5
28
29 #define eps 1e-10
30
31 #define ll long long
32
33 #define pa pair<int,int>
34
35 #define for0(i,n) for(int i=0;i<=(n);i++)
36
37 #define for1(i,n) for(int i=1;i<=(n);i++)
38
39 #define for2(i,x,y) for(int i=(x);i<=(y);i++)
40
41 #define for3(i,x,y) for(int i=(x);i>=(y);i--)
42
43 #define for4(i,x) for(int i=head[x],y=e[i].go;i;i=e[i].next,y=e[i].go)
44
45 #define for5(n,m) for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)
46
47 #define mod 1000000007
48
49 using namespace std;
50
51 inline int read()
52
53 {
54
55 int x=0,f=1;char ch=getchar();
56
57 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
58
59 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}
60
61 return x*f;
62
63 }
64 int b[20];
65 inline void print(int x)
66 {
67 for(b[0]=0;x;b[++b[0]]=x%10,x/=10);
68 for3(i,b[0],1)putchar(‘0‘+b[i]);
69 putchar(‘\n‘);
70 }
71 int n,m,k,top;
72 int fa[maxn],f[maxn],c[maxn][2],sta[maxn],mx[maxn],val[maxn],ans[maxn];
73 struct rec{int u,v,w,id,del;}e[maxn];
74 bool rev[maxn];
75 bool operator<(rec a,rec b){return a.u==b.u?a.v<b.v:a.u<b.u;}
76 inline bool cmp(rec a,rec b){return a.w<b.w;}
77 inline bool cmp1(rec a,rec b){return a.id<b.id;}
78 inline int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
79 inline int find(int u,int v)
80 {
81 int l=1,r=m;
82 while(l<=r)
83 {
84 int mid=(l+r)>>1;
85 if(e[mid].u<u||(e[mid].u==u&&e[mid].v<v))l=mid+1;else r=mid-1;
86 }
87 return l;
88 }
89 inline bool isroot(int x){return c[fa[x]][0]!=x&&c[fa[x]][1]!=x;}
90 inline void pushup(int x)
91 {
92 int l=c[x][0],r=c[x][1];
93 mx[x]=x;
94 if(val[mx[l]]>val[mx[x]])mx[x]=mx[l];
95 if(val[mx[r]]>val[mx[x]])mx[x]=mx[r];
96 }
97 inline void rotate(int x)
98 {
99 int y=fa[x],z=fa[y],l=c[y][1]==x,r=l^1;
100 if(!isroot(y))c[z][c[z][1]==y]=x;
101 fa[x]=z;fa[y]=x;fa[c[x][r]]=y;
102 c[y][l]=c[x][r];c[x][r]=y;
103 pushup(y);pushup(x);
104 }
105 inline void update(int x)
106 {
107 rev[x]^=1;
108 swap(c[x][0],c[x][1]);
109 }
110 inline void pushdown(int x)
111 {
112 if(!rev[x])return;
113 rev[x]=0;
114 update(c[x][0]);update(c[x][1]);
115 }
116 inline void splay(int x)
117 {
118 sta[top=1]=x;
119 for(int y=x;!isroot(y);y=fa[y])sta[++top]=fa[y];
120 while(top)pushdown(sta[top--]);
121 while(!isroot(x))
122 {
123 int y=fa[x],z=fa[y];
124 if(!isroot(y))
125 {
126 if((c[z][0]==y)^(c[y][0]==x))rotate(x);else rotate(y);
127 }
128 rotate(x);
129 }
130 }
131 inline void access(int x)
132 {
133 for(int y=0;x;x=fa[x])
134 {
135 splay(x);c[x][1]=y;pushup(x);y=x;
136 }
137 }
138 inline void makeroot(int x)
139 {
140 access(x);splay(x);update(x);
141 }
142 inline void cut(int x,int y)
143 {
144 makeroot(x);access(y);splay(y);c[y][0]=fa[x]=0;
145 }
146 inline void link(int x,int y)
147 {
148 makeroot(x);fa[x]=y;
149 }
150 inline int query(int x,int y)
151 {
152 makeroot(x);access(y);splay(y);return mx[y];
153 }
154
155 int main()
156
157 {
158
159 freopen("input.txt","r",stdin);
160
161 freopen("output.txt","w",stdout);
162
163 n=read();m=read();k=read();
164 for1(i,n)f[i]=i;
165 for1(i,m){e[i].u=read();e[i].v=read();e[i].w=read();if(e[i].u>e[i].v)swap(e[i].u,e[i].v);}
166 sort(e+1,e+m+1,cmp);
167 for1(i,m)
168 {
169 e[i].id=i;
170 val[n+i]=e[i].w;
171 mx[n+i]=n+i;
172 }
173 sort(e+1,e+m+1);
174 for1(i,k)
175 {
176 int ch=read();e[m+i].u=read();e[m+i].v=read();
177 if(ch==2)
178 {
179 if(e[m+i].u>e[m+i].v)swap(e[m+i].u,e[m+i].v);
180 int t=find(e[m+i].u,e[m+i].v);
181 e[t].del=1;e[m+i].w=e[t].id;
182 }
183 }
184 sort(e+1,e+m+1,cmp1);
185 int cnt=0;
186 for1(i,m)if(!e[i].del)
187 {
188 int u=e[i].u,v=e[i].v,x=find(u),y=find(v);
189 if(x!=y)
190 {
191 f[y]=x;
192 link(u,i+n);link(v,i+n);
193 if(++cnt==n-1)break;
194 }
195 }
196 for3(i,k,1)
197 {
198 //cout<<i<<endl;
199 if(!e[m+i].w)ans[i]=val[query(e[m+i].u,e[m+i].v)];
200 else
201 {
202 int u=e[m+i].u,v=e[m+i].v,t1=e[m+i].w,t2=query(u,v);
203 if(e[t1].w<val[t2])
204 {
205 cut(e[t2-n].u,t2);cut(e[t2-n].v,t2);
206 link(u,t1+n);link(v,t1+n);
207 }
208 }
209 }
210 for1(i,k)if(ans[i])print(ans[i]);
211
212 return 0;
213
214 }