1 #include<cstdio>
2 #include<cstdlib>
3 #include<cmath>
4 #include<cstring>
5 #include<algorithm>
6 #include<iostream>
7 #include<vector>
8 #include<map>
9 #include<set>
10 #include<queue>
11 #include<string>
12 #define inf 1000000000
13 #define maxn 1100000+1000
14 #define maxm 100000+10000
15 #define eps 1e-10
16 #define ll long long
17 #define pa pair<int,int>
18 #define for0(i,n) for(int i=0;i<=n;i++)
19 #define for1(i,n) for(int i=1;i<=n;i++)
20 #define for2(i,x,y) for(int i=x;i<=y;i++)
21 using namespace std;
22 inline int read()
23 {
24 int x=0,f=1;char ch=getchar();
25 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
26 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();}
27 return x*f;
28 }
29 struct rec{int x,y,w;}e[maxn];
30 struct rec1{int x,id;}b[maxm];
31 struct rec2{int ch,x,y,id,ans;}a[maxm];
32 int n,m,q,tot=1,ans[maxm],fa[maxn],c[maxn][2],sta[maxn],f[maxn],next[maxn],mx[maxn],v[maxn];
33 bool rev[maxn],flag[maxn];
34 inline bool isroot(int x)
35 {
36 return c[fa[x]][0]!=x&&c[fa[x]][1]!=x;
37 }
38 inline void pushup(int x)
39 {
40 mx[x]=x;
41 if(v[mx[c[x][0]]]>v[mx[x]])mx[x]=mx[c[x][0]];
42 if(v[mx[c[x][1]]]>v[mx[x]])mx[x]=mx[c[x][1]];
43 }
44 inline void rotate(int x)
45 {
46 int y=fa[x],z=fa[y],l=(c[y][1]==x),r=l^1;
47 if(!isroot(y))c[z][c[z][1]==y]=x;
48 fa[x]=z;fa[y]=x;fa[c[x][r]]=y;
49 c[y][l]=c[x][r];c[x][r]=y;
50 pushup(y);pushup(x);
51 }
52 inline void pushdown(int x)
53 {
54 if(!rev[x])return;
55 rev[x]^=1;rev[c[x][0]]^=1;rev[c[x][1]]^=1;
56 swap(c[x][0],c[x][1]);
57 }
58 inline void splay(int x)
59 {
60 int top=0;sta[++top]=x;
61 for(int y=x;!isroot(y);y=fa[y])sta[++top]=fa[y];
62 for(;top;)pushdown(sta[top--]);
63 while(!isroot(x))
64 {
65 int y=fa[x],z=fa[y];
66 if(!isroot(y))
67 {
68 if(c[z][0]==y^c[y][0]==x)rotate(x);else rotate(y);
69 }
70 rotate(x);
71 }
72 }
73 inline void access(int x)
74 {
75 for(int y=0;x;x=fa[x])
76 {
77 splay(x);c[x][1]=y;pushup(x);y=x;
78 }
79 }
80 inline void makeroot(int x)
81 {
82 access(x);splay(x);rev[x]^=1;
83 }
84 inline int ask(int x,int y)
85 {
86 makeroot(x);access(y);splay(y);return mx[y];
87 }
88 inline void link(int x,int y)
89 {
90 makeroot(x);fa[x]=y;splay(x);
91 }
92 inline void cut(int x,int y)
93 {
94 makeroot(x);access(y);splay(y);c[y][0]=fa[x]=0;
95 }
96 inline int find(int x)
97 {
98 return f[x]==x?x:f[x]=find(f[x]);
99 }
100 inline void insert(int i)
101 {
102 int x=e[i].x,y=e[i].y,xx=find(x),yy=find(y),z;
103 if(xx!=yy)
104 {
105 f[xx]=yy;
106 link(x,n+i);link(y,n+i);
107 }
108 else
109 {
110 z=ask(x,y);
111 if(e[i].w<v[z])
112 {
113 cut(e[z-n].x,z);cut(e[z-n].y,z);
114 link(x,n+i);link(y,n+i);
115 }
116 }
117 }
118 inline int search(int x)
119 {
120 int l=1,r=tot,mid;
121 while(l<r)
122 {
123 mid=(l+r)>>1;
124 if(b[mid].x<x)l=mid+1;else r=mid;
125 }
126 return b[l].id>>1;;
127 }
128 inline bool cmp(rec1 a,rec1 b)
129 {
130 return a.x<b.x;
131 }
132 int main()
133 {
134 freopen("input.txt","r",stdin);
135 freopen("output.txt","w",stdout);
136 n=read();m=read();q=read();
137 for1(i,m)e[i].x=read(),e[i].y=read(),e[i].w=read(),b[++tot].x=e[i].x*n+e[i].y,b[++tot].x=e[i].y*n+e[i].x;
138 for1(i,tot)b[i].id=i;
139 sort(b+1,b+tot+1,cmp);
140 for1(i,q)a[q+1-i].ch=read(),a[q+1-i].x=read(),a[q+1-i].y=read();
141 for1(i,q)if(a[i].ch==2)a[i].id=search(a[i].x*n+a[i].y),flag[a[i].id]=1;
142 for1(i,m)v[n+i]=e[i].w,mx[n+i]=n+i;
143 for1(i,n)f[i]=i;
144 for1(i,m)if(!flag[i])insert(i);
145 for1(i,q)
146 {
147 if(a[i].ch==1)a[i].ans=v[ask(a[i].x,a[i].y)];
148 else insert(a[i].id);
149 }
150 for(int i=q;i>=1;i--)if(a[i].ch==1)printf("%d\n",a[i].ans);
151 return 0;
152 }