#include <bits/stdc++.h>
using namespace std;
const int maxn = 300001;
const int INF = 1 << 29;
vector<int> G[maxn];
int dp[maxn][2], gao[maxn][2];
int fa[maxn], vis[maxn], miv[maxn], lab[maxn];
int n, m, q;
int find(int x) {
  if (x != fa[x]) fa[x] = find(fa[x]);
  return fa[x];
}
void dfs1(int u, int f) {
  vis[u] = 1;
  dp[u][0] = 0;
  dp[u][1] = 0;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == f) continue;
    dfs1(v, u);
    if (dp[v][0] + 1 > dp[u][0]) {
      dp[u][1] = dp[u][0];
      dp[u][0] = dp[v][0] + 1;
    } else if (dp[v][0] + 1 > dp[u][1])
      dp[u][1] = dp[v][0] + 1;
  }
}
void dfs2(int u, int f, int len) {
  vis[u] = 1;
  gao[u][0] = dp[u][0];
  gao[u][1] = dp[u][1];
  if (len > gao[u][0])
    gao[u][1] = gao[u][0], gao[u][0] = len;
  else if (len > gao[u][1])
    gao[u][1] = len;
  int x = find(u);
  if (gao[u][0] < miv[x]) {
    miv[x] = gao[u][0];
    lab[x] = u;
  }
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == f) continue;
    int tmp = dp[u][0];
    if (tmp == dp[v][0] + 1) tmp = dp[u][1];
    dfs2(v, u, max(len, tmp) + 1);
  }
}
int main() {
  while (cin >> n >> m >> q) {
    int u, v, op;
    for (int i = 1; i <= n; i++) fa[i] = i;
    for (int i = 0; i < m; i++) {
      scanf("%d%d", &u, &v);
      G[u].push_back(v);
      G[v].push_back(u);
      int x = find(u), y = find(v);
      if (x != y) fa[x] = y;
    }
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; i++)
      if (!vis[i]) dfs1(i, -1);
    for (int i = 1; i <= n; i++) miv[i] = INF;
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; i++)
      if (!vis[i]) dfs2(i, -1, -1);
    while (q--) {
      scanf("%d", &op);
      if (op == 1) {
        scanf("%d", &u);
        int x = lab[find(u)];
        printf("%d\n", gao[x][0] + gao[x][1]);
      } else {
        scanf("%d%d", &u, &v);
        int x = lab[find(u)], y = lab[find(v)];
        if (x != y) {
          if (gao[x][0] > gao[y][0]) {
            swap(x, y);
            swap(u, v);
          }
          fa[find(u)] = find(v);
          int t = gao[x][0] + 1;
          if (t > gao[y][0])
            gao[y][1] = gao[y][0], gao[y][0] = t;
          else if (t > gao[y][1])
            gao[y][1] = t;
        }
      }
    }
  }
  return 0;
}
