填坑!
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=(n);i++)
#define ls ch[x][0]
#define rs ch[x][1]
using namespace std;
const int maxt = 1500005;
const int maxn=100005;
const int maxm=1000005;
const int maxq=100005;
int sc() {
char ch = getchar();
while(ch<'0'||ch>'9')
ch=getchar();
int tmp = 0;
for(; '0' <= ch && ch <= '9'; ch = getchar())tmp = tmp * 10 + ch - '0';
return tmp;
}
struct LCT {
int ch[maxt][2], fa[maxt], rev[maxt], mx[maxt], val[maxt];
void up(int x) {
mx[x] = x;
if(val[mx[ls]] > val[mx[x]])mx[x] = mx[ls];
if(val[mx[rs]] > val[mx[x]])mx[x] = mx[rs];
}
bool isroot(int x){return !x || (ch[fa[x]][0]!=x && ch[fa[x]][1]!=x);}
void flip(int x){swap(ls,rs),rev[x]^=1;}
void down(int x){if(rev[x]){rev[x]=0;flip(ls);flip(rs);}}
void relax(int x){if (!isroot(x)) relax(fa[x]);down(x);}
void rotate(int x,int d){
int y=fa[x];
ch[y][d^1]=ch[x][d];
fa[ch[x][d]]=y;
if(!isroot(y))ch[fa[y]][ch[fa[y]][1]==y]=x;
fa[x]=fa[y];
ch[x][d]=y;
fa[y]=x;
up(y);
}
void splay(int x){
relax(x);
while(!isroot(x)){
if(isroot(fa[x]))rotate(x,(ch[fa[x]][0]==x));
else{int y=fa[x];
int d=(ch[fa[y]][0]==y);
if(ch[y][d]==x){
rotate(x,d^1);
rotate(x,d);
}
else{rotate(y,d);
rotate(x,d);
}
}
}
up(x);
}
int access(int x){int y=0;
for(;x;y=x,x=fa[x]){
splay(x);
ch[x][1]=y;
up(x);
}return y;
}
void makeroot(int x){access(x);
splay(x);
flip(x);}
void link(int x,int y){makeroot(x);fa[x]=y;} //在x成为y的孩子后,原x所在树x至根的深度应该翻转,不然不是树;
void cut(int x,int y){makeroot(x);access(y);splay(y);ch[y][0]=fa[x]=0;}
int query(int x,int y){makeroot(x);
access(y);
splay(y);
return mx[y];}
}lct; //其维护的是一种连接关系;
/*struct LCT2{
int fa[maxt],ch[maxt][2],val[maxt],mx[maxt];bool rev[maxt];
int which(int x){return ch[fa[x]][1]==x;}
bool isroot(int x){return ch[fa[x]][0]!=x&&ch[fa[x]][1]!=x;}
void update(int x){
mx[x]=x;
if (val[mx[ls]]>val[mx[x]]) mx[x]=mx[ls];
if (val[mx[rs]]>val[mx[x]]) mx[x]=mx[rs];
}
void flip(int x){swap(ls,rs),rev[x]^=1;}
void down(int x){if (rev[x]) flip(ch[x][0]),flip(ch[x][1]),rev[x]^=1;}
void relax(int x){if (!isroot(x)) relax(fa[x]);down(x);}
void rotate(int x){
int y=fa[x],z=fa[y],nx=which(x),ny=which(y);
fa[ch[x][!nx]]=y,ch[y][nx]=ch[x][!nx];
fa[x]=z;if (!isroot(y)) ch[z][ny]=x;
fa[y]=x,ch[x][!nx]=y;update(y);
}
void splay(int x){
relax(x);
while (!isroot(x)){
if (isroot(fa[x])) rotate(x);
else if (which(x)==which(fa[x])) rotate(fa[x]),rotate(x);
else rotate(x),rotate(x);
}
update(x);
}
void access(int x){for (int p=0;x;p=x,x=fa[x]) splay(x),fa[ch[x][1]=p]=x,update(x);}
void makeroot(int x){access(x),splay(x),flip(x);}
void link(int a,int b){makeroot(a),fa[a]=b;}
void cut(int a,int b){makeroot(a),access(b),splay(b),ch[b][0]=fa[a]=0;}
int query(int a,int b){makeroot(a),access(b),splay(b);return mx[b];}
}lct;
*/
int n,m,q;
struct E{int x,y,w,id,vis;E(int x=0,int y=0,int w=0,int id=0,int vis=0):x(x),y(y),w(w),id(id),vis(vis){}
}e[maxm];int top=0;
bool cmp_find(E a,E b){return a.x==b.x ? a.y<b.y : a.x<b.x;}
bool cmp_w(E a,E b){return a.w<b.w;}
bool cmp_id(E a,E b){return a.id<b.id;}
int p[maxn];
int jfind(int x){return p[x]==x ? x : p[x]=jfind(p[x]);}
int find(int x,int y){int l=1,r=m;
while(l<=r){
int mid=(l+r)>>1;
if(e[mid].x==x && e[mid].y==y){e[mid].vis=1;return mid;}
else if(e[mid].x>x || (e[mid].x==x && e[mid].y>y))r=mid-1;
else l=mid+1;
}
}
struct Q{
int op,x,y,ans,id;
}que[maxq];
void kruskal(){rep(i,1,n)p[i]=i;
sort(e+1,e+1+m,cmp_id);
int tot=0;
rep(i,1,m){
int x=e[i].x;int y=e[i].y;int px=jfind(x);int py=jfind(y);
if(px!=py && !e[i].vis){p[px]=py;
lct.link(x,n+i);
lct.link(y,n+i);
if(++tot==n-1)return;
}
}
}
int main() {//freopen("in.in","r",stdin);
//freopen("out.out","w",stdout);
n=sc();m=sc();q=sc();
rep(i,1,m){e[i].x=sc();e[i].y=sc(); e[i].w=sc();
if(e[i].x>e[i].y)swap(e[i].x,e[i].y);
}
sort(e+1,e+1+m,cmp_w);
rep(i,1,m)e[i].id=i,lct.val[i+n]=e[i].w,lct.mx[i+n]=i+n;
sort(e+1,e+1+m,cmp_find);
rep(i,1,q)
{que[i].op=sc();que[i].x=sc();que[i].y=sc();if(que[i].x>que[i].y)swap(que[i].x,que[i].y);
if(que[i].op==2){
que[i].id=e[find(que[i].x,que[i].y)].id;
}
}
kruskal();
for(int i=q;i;i--){
if(que[i].op==2){
int kk=que[i].id;
int t=lct.query(que[i].x,que[i].y);
if(e[kk].w<lct.val[t]){
lct.cut(e[t-n].x,t);
lct.cut(e[t-n].y,t);
lct.link(que[i].x,n+kk);
lct.link(que[i].y,n+kk);
}
}
else{que[i].ans=lct.val[lct.query(que[i].x,que[i].y)];
}
}
rep(i,1,q)if(que[i].op==1)printf("%d\n",que[i].ans);
return 0;
}