1 #include<iostream>
2 #include<algorithm>
3 #include<cstdio>
4 #include<cstring>
5 using namespace std;
6 inline int read()
7 {
8 int x=0,f=1;char ch=getchar();
9 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
10 while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
11 return x*f;
12 }
13 int n,m,Q,top;
14 int f[1500005];
15 int fa[1500005],c[1500005][2],s[1500005];
16 int mx[1500005],val[1500005];
17 bool rev[1500005];
18 struct edge{int u,v,w,id;bool d;}e[1000005];
19 struct que{int f,x,y,ans,id;}q[100005];
20 bool operator<(edge a,edge b)
21 {
22 return a.u<b.u||(a.u==b.u&&a.v<b.v);
23 }
24 bool cmp(edge a,edge b)
25 {
26 return a.w<b.w;
27 }
28 bool cmp2(edge a,edge b)
29 {
30 return a.id<b.id;
31 }
32 int getf(int x){return x==f[x]?x:f[x]=getf(f[x]);}
33 int find(int u,int v)
34 {
35 int l=1,r=m;
36 while(l<=r)
37 {
38 int mid=(l+r)>>1;
39 if(e[mid].u<u||(e[mid].u==u&&e[mid].v<v))l=mid+1;
40 else if(e[mid].u==u&&e[mid].v==v)return mid;
41 else r=mid-1;
42 }
43 }
44 bool isroot(int x)
45 {
46 return c[fa[x]][0]!=x&&c[fa[x]][1]!=x;
47 }
48 void update(int x)
49 {
50 int l=c[x][0],r=c[x][1];
51 mx[x]=x;
52 if(val[mx[l]]>val[mx[x]])mx[x]=mx[l];
53 if(val[mx[r]]>val[mx[x]])mx[x]=mx[r];
54 }
55 void rotate(int x)
56 {
57 int y=fa[x],z=fa[y],l,r;
58 if(c[y][0]==x)l=0;else l=1;r=l^1;
59 if(!isroot(y))
60 {
61 if(c[z][0]==y)c[z][0]=x;else c[z][1]=x;
62 }
63 fa[x]=z;fa[y]=x;fa[c[x][r]]=y;
64 c[y][l]=c[x][r];c[x][r]=y;
65 update(y);update(x);
66 }
67 void pushdown(int x)
68 {
69 int l=c[x][0],r=c[x][1];
70 if(rev[x])
71 {
72 rev[x]^=1;
73 rev[l]^=1;rev[r]^=1;
74 swap(c[x][0],c[x][1]);
75 }
76 }
77 void splay(int x)
78 {
79 top=0;s[++top]=x;
80 for(int i=x;!isroot(i);i=fa[i])
81 s[++top]=fa[i];
82 for(int i=top;i;i--)
83 pushdown(s[i]);
84 while(!isroot(x))
85 {
86 int y=fa[x],z=fa[y];
87 if(!isroot(y))
88 {
89 if(c[y][0]==x^c[z][0]==y)rotate(x);
90 else rotate(y);
91 }
92 rotate(x);
93 }
94 }
95 void access(int x)
96 {
97 int t=0;
98 while(x)
99 {
100 splay(x);c[x][1]=t;update(x);t=x;x=fa[x];
101 }
102 }
103 void makeroot(int x)
104 {
105 access(x);splay(x);rev[x]^=1;
106 }
107 void link(int x,int y)
108 {
109 makeroot(x);fa[x]=y;
110 }
111 void cut(int x,int y)
112 {
113 makeroot(x);access(y);splay(y);c[y][0]=fa[x]=0;
114 }
115 int query(int x,int y)
116 {
117 makeroot(x);access(y);splay(y);return mx[y];
118 }
119 int main()
120 {
121 n=read();m=read();Q=read();
122 for(int i=1;i<=n;i++)f[i]=i;
123 for(int i=1;i<=m;i++)
124 {
125 e[i].u=read(),e[i].v=read(),e[i].w=read();
126 if(e[i].u>e[i].v)swap(e[i].u,e[i].v);
127 }
128 sort(e+1,e+m+1,cmp);
129 for(int i=1;i<=m;i++)
130 {
131 e[i].id=i;
132 val[n+i]=e[i].w;
133 mx[n+i]=n+i;
134 }
135 sort(e+1,e+m+1);
136 for(int i=1;i<=Q;i++)
137 {
138 q[i].f=read(),q[i].x=read(),q[i].y=read();
139 if(q[i].f==2)
140 {
141 if(q[i].x>q[i].y)swap(q[i].x,q[i].y);
142 int t=find(q[i].x,q[i].y);
143 e[t].d=1;q[i].id=e[t].id;
144 }
145 }
146 sort(e+1,e+m+1,cmp2);
147 int tot=0;
148 for(int i=1;i<=m;i++)
149 if(!e[i].d)
150 {
151 int u=e[i].u,v=e[i].v,x=getf(u),y=getf(v);
152 if(x!=y)
153 {
154 f[x]=y;
155 link(u,i+n);link(v,i+n);
156 tot++;
157 if(tot==n-1)break;
158 }
159 }
160 for(int i=Q;i;i--)
161 {
162 if(q[i].f==1)
163 q[i].ans=val[query(q[i].x,q[i].y)];
164 else
165 {
166 int u=q[i].x,v=q[i].y,k=q[i].id;
167 int t=query(u,v);
168 if(e[k].w<val[t])
169 {
170 cut(e[t-n].u,t);cut(e[t-n].v,t);
171 link(u,k+n);link(v,k+n);
172
173 }
174 }
175 }
176 for(int i=1;i<=Q;i++)
177 if(q[i].f==1)printf("%d\n",q[i].ans);
178 return 0;
179 }