#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>
using namespace std;
#define MAXM 1100000
#define MAXN 110000
#define MAXQ 110000
#define MAXT MAXM+MAXN
inline int nextInt()
{
register char ch;
register int x=0;
while (ch=getchar(),ch<‘0‘ || ch>‘9‘);
do
x=x*10+ch-‘0‘;
while (ch=getchar(),ch<=‘9‘ && ch>=‘0‘);
return x;
}
int n,m,q;
int ch[MAXT][2],pnt[MAXT];
int mx[MAXT],mt[MAXT];
int val[MAXT],siz[MAXT],pos[MAXT];
bool rev[MAXT];
int stack[MAXT],tops=-1;
inline bool is_root(int now)
{
return !pnt[now] || (ch[pnt[now]][0]!=now && ch[pnt[now]][1]!=now);
}
inline void update(int now)
{
siz[now]=siz[ch[now][0]]+siz[ch[now][1]]+1;
if (mx[ch[now][0]]>mx[ch[now][1]])
{
mx[now]=mx[ch[now][0]];
mt[now]=mt[ch[now][0]];
}else
{
mx[now]=mx[ch[now][1]];
mt[now]=mt[ch[now][1]];
}
if (mx[now]<val[now])
{
mx[now]=val[now];
mt[now]=now;
}
}
inline void reverse(int now)
{
if (!now)return ;
swap(ch[now][0],ch[now][1]);
rev[now]^=1;
}
inline void down(int now)
{
if (rev[now])
{
reverse(ch[now][0]);
reverse(ch[now][1]);
rev[now]=0;
}
}
inline void rotate(int now)
{
register int p=pnt[now],anc=pnt[p];
register int dir=ch[p][0]==now;
if (!is_root(pnt[now]))
ch[anc][ch[anc][1]==p]=now;
pnt[now]=anc;
if (ch[now][dir])
pnt[ch[now][dir]]=p;
ch[p][1-dir]=ch[now][dir];
pnt[p]=now;
ch[now][dir]=p;
update(p);
update(now);
}
void splay(int now)
{
int x=now;
stack[++tops]=x;
while (!is_root(x))
{
x=pnt[x];
stack[++tops]=x;
}
while (~tops)
down(stack[tops--]);
while (!is_root(now))
{
int p=pnt[now],anc=pnt[p];
if (is_root(p))
rotate(now);
else if ((ch[anc][0]==p) == (ch[p][0]==now))
rotate(p),rotate(now);
else
rotate(now),rotate(now);
}
}
int access(int now)
{
int son=0;
while (now)
{
splay(now);
ch[now][1]=son;
son=now;
update(now);
now=pnt[now];
}
return son;
}
inline void make_root(int now)
{
access(now);
splay(now);
reverse(now);
}
struct aaa
{
int x,y,d,id;
}el[MAXM],e[MAXM];
struct bbb
{
int x,y,d,t,id;
}qur[MAXQ];
bool operator <(aaa a1,aaa a2)
{
if (a1.x==a2.x)return a1.y<a2.y;
return a1.x<a2.x;
}
set<aaa> S;
bool cmp_d(aaa a1,aaa a2)
{
return a1.d<a2.d;
}
int uf[MAXN];
int get_fa(int now)
{
return now==uf[now] ? now : uf[now]=get_fa(uf[now]);
}
bool comb(int x,int y)
{
x=get_fa(x);
y=get_fa(y);
if (x==y)return false;
uf[x]=y;
return true;
}
void add_edge(int x,int y)
{
//cout<<"Add:"<<x<<" "<<y<<endl;
make_root(x);
make_root(y);
ch[x][0]=y;
pnt[y]=x;
update(x);
}
void erase_edge(int x,int y)
{
//cout<<"Del:"<<x<<" "<<y<<endl;
make_root(x);
access(y);
splay(x);
if (ch[x][0]==y)
{
splay(y);
ch[y][1]=pnt[x]=0;
update(y);
}else if (ch[x][1]==y)
{
ch[x][1]=pnt[y]=0;//注意清空pnt[]
update(x);
}else throw 1;
}
vector<int> ans;
pair<int,int> Qry_path(int x,int y)
{
make_root(x);
int t=access(y);
return make_pair(mx[t],mt[t]-n-1);
}
int main()
{
freopen("input.txt","r",stdin);
int i,j,k;
scanf("%d%d%d",&n,&m,&q);
aaa at;
for (i=1;i<=n;i++)uf[i]=i;
for (i=0;i<m;i++)
{
at.x=nextInt();at.y=nextInt();at.d=nextInt();
//scanf("%d%d%d",&at.x,&at.y,&at.d);
val[n+i+1]=at.d;
at.id=i;
if (at.x>at.y)
swap(at.x,at.y);
S.insert(at);
el[i]=at;
}
set<aaa>::iterator it1;
for (i=0;i<q;i++)
{
qur[i].t=nextInt();qur[i].x=nextInt();qur[i].y=nextInt();
//scanf("%d%d%d",&qur[i].t,&qur[i].x,&qur[i].y);
if (qur[i].t==2)
{
if (qur[i].x>qur[i].y)
swap(qur[i].x,qur[i].y);
at.x=qur[i].x,at.y=qur[i].y;
it1=S.find(at);
qur[i].d=it1->d;
qur[i].id=it1->id;
S.erase(it1);
}
}
m=0;
for (it1=S.begin();it1!=S.end();it1++)
{
e[m++]=*it1;
}
sort(e,e+m,cmp_d);
for (i=0;i<m;i++)
{
if (comb(e[i].x,e[i].y))
{
add_edge(e[i].x,n+e[i].id+1);
add_edge(e[i].y,n+e[i].id+1);
}
}
for (i=q-1;i>=0;i--)
{
if (qur[i].t==2)
{
pair<int,int> pr;
pr=Qry_path(qur[i].x,qur[i].y);
if (pr.first<=qur[i].d)continue;
erase_edge(el[pr.second].x,pr.second+1+n);
erase_edge(el[pr.second].y,pr.second+1+n);
add_edge(qur[i].x,qur[i].id+n+1);
add_edge(qur[i].y,qur[i].id+n+1);
}else
{
pair<int,int> pr;
pr=Qry_path(qur[i].x,qur[i].y);
ans.push_back(pr.first);
//printf("%d\n",pr.first);
}
}
while (ans.size())
{
printf("%d\n",ans[ans.size()-1]);
ans.pop_back();
}
}