#include using LL = long long; const int N = 1e5 + 7; const int T = 1 << 18 | 7; int n, m, q, c, max[T]; std::map pos; std::vector tr[N], gr[N]; std::priority_queue w[N]; int stk[N], *stp = stk, dfn[N], low[N], cnt, bel[N]; int dep[N], fa[N], sz[N], son[N]; int seq[N], top[N], tot; void tarjan(int x, int y) { *++stp = x; dfn[x] = low[x] = ++cnt; for(int v: gr[x]) if(v != y) if(!dfn[v]) { tarjan(v, x); low[x] = std::min(low[x], low[v]); } else low[x] = std::min(low[x], dfn[v]); if(low[x] == dfn[x]) { while(*stp != x) bel[*stp--] = x; bel[*stp--] = x; } } void dfs(int x) { sz[x] = 1; for(int v: tr[x]) { fa[v] = x; dep[v] = dep[x] + 1; dfs(v); sz[x] += sz[v]; if(sz[v] > sz[son[x]]) son[x] = v; } } void dfs(int x, int y) { top[x] = y; seq[x] = ++tot; if(son[x]) dfs(son[x], y); for(int v: tr[x]) if(v != son[x]) dfs(v, v); } void modify(int x, int y) { max[x += c] = y; while(x >>= 1) max[x] = std::max(max[x << 1], max[x << 1 | 1]); } int ask(int l, int r) { int ret = -1; for(l += c - 1, r += c + 1; l ^ r ^ 1; l >>= 1, r >>= 1) { if(~l & 1) ret = std::max(ret, max[l ^ 1]); if( r & 1) ret = std::max(ret, max[r ^ 1]); } return ret; } void mfy(int x, int y) { pos[y] = bel[x]; w[bel[x]].push(y); modify(bel[x], w[bel[x]].top()); } int qry(int x, int y) { x = bel[x]; y = bel[y]; int ret = -1; while(top[x] != top[y]) { if(dep[top[x]] < dep[top[y]]) std::swap(x, y); ret = std::max(ret, ask(seq[top[x]], seq[x])); x = fa[top[x]]; } if(dep[x] > dep[y]) std::swap(x, y); ret = std::max(ret, ask(seq[x], seq[y])); if(ret != -1) { w[pos[ret]].pop(); modify(pos[ret], w[pos[ret]].empty() ? -1 : w[pos[ret]].top()); } return ret; } int main() { scanf("%d%d%d", &n, &m, &q); for(int i = 1, x, y; i <= m; ++i) { scanf("%d%d", &x, &y); gr[x].push_back(y); gr[y].push_back(x); } tarjan(1, 0); for(int i = 1; i <= n; ++i) for(int j: gr[i]) if(bel[i] != bel[j] && dfn[i] < dfn[j]) tr[bel[i]].push_back(bel[j]); dfs(1); dfs(1, 1); memset(max, -1, sizeof max); for(c = tot + 2; c & c - 1; c += c & -c) ; while(q--) { int t, x, y; scanf("%d%d%d", &t, &x, &y); if(t == 1) mfy(x, y); else printf("%d\n", qry(x, y)); } return 0; }