#include <bits/stdc++.h>
using namespace std;
template <typename T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int maxn = 300005;
int dsu[maxn];
int center[maxn], centerDist[maxn], diam[maxn];
int find(int v) {
  if (dsu[v] == v) return v;
  return dsu[v] = find(dsu[v]);
}
void unite(int a, int b) {
  int i = find(a);
  int j = find(b);
  if (i != j) {
    if (rand() & 1) swap(i, j);
    dsu[i] = j;
    diam[j] =
        max(max(diam[j], diam[i]), (diam[j] + 1) / 2 + 1 + (diam[i] + 1) / 2);
    if (max(centerDist[i], 1 + centerDist[j]) <
        max(centerDist[j], centerDist[i] + 1)) {
      center[j] = center[i];
      centerDist[j] = max(centerDist[i], 1 + centerDist[j]);
    } else {
      centerDist[j] = max(centerDist[j], centerDist[i] + 1);
    }
  }
}
vector<int> g[maxn];
int used[maxn];
int currUsed = 1;
pair<int, int> ff[maxn];
int dfs(int v, int p) {
  ff[v] = make_pair(0, 0);
  int res = 0;
  for (int to : g[v]) {
    if (to == p) continue;
    int curr = dfs(to, v) + 1;
    res = max(curr, res);
    if (curr > ff[v].first) {
      ff[v].second = ff[v].first;
      ff[v].first = curr;
    } else if (res > ff[v].second) {
      ff[v].second = curr;
    }
  }
  return res;
}
pair<int, int> ans;
void dfs2(int v, int p, int up = 0) {
  ans = min(ans, make_pair(max(up, ff[v].first), v));
  for (int to : g[v]) {
    if (to == p) continue;
    int h = up + 1;
    if (ff[to].first + 1 == ff[v].first)
      h = max(h, ff[v].second + 1);
    else
      h = max(h, ff[v].first + 1);
    dfs2(to, v, h);
  }
}
int main(int argc, char *argv[]) {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    dsu[i] = i;
    center[i] = i;
    centerDist[i] = 0;
    diam[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
    unite(u, v);
  }
  for (int i = 1; i <= n; i++) {
    if (used[i]) continue;
    currUsed++;
    pair<int, int> res = make_pair(0, i);
    for (int h = 0; h < 2; h++) {
      currUsed++;
      queue<pair<int, int> > q;
      q.push(make_pair(0, res.second));
      used[res.second] = currUsed;
      while (!q.empty()) {
        int v = q.front().second;
        int dist = q.front().first;
        res = max(res, q.front());
        q.pop();
        for (int to : g[v]) {
          if (used[to] == currUsed) continue;
          used[to] = currUsed;
          q.push(make_pair(dist + 1, to));
        }
      }
    }
    diam[find(i)] = res.first;
    ans = make_pair(1e9, -1);
    dfs(i, i);
    dfs2(i, i, 0);
    center[find(i)] = ans.second;
    centerDist[find(i)] = ans.first;
  }
  for (int i = 0; i < q; i++) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      int x;
      scanf("%d", &x);
      printf("%d\n", diam[find(x)]);
    } else {
      int u, v;
      scanf("%d %d", &u, &v);
      unite(u, v);
    }
  }
  return 0;
}
