#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int A[300100];
int e[300100];
int lp[300100];
int dist[300100];
vector<int> G[300100];
vector<int> V;
inline void unionS(int x, int y) { A[y] = x; }
inline int findS(int x) { return (A[x] < 0) ? x : (A[x] = findS(A[x])); }
void elp(int u) {
  int init = u;
  dist[u] = 0;
  V = *new vector<int>();
  queue<int> Q;
  Q.push(u);
  while (Q.size() > 0) {
    int x = Q.front();
    V.push_back(x);
    Q.pop();
    for (int i = (0); i < (G[x].size()); i++) {
      if (dist[G[x][i]] > dist[x] + 1) {
        dist[G[x][i]] = dist[x] + 1;
        Q.push(G[x][i]);
      }
    }
  }
  for (int i = (0); i < (V.size()); i++) {
    if (dist[V[i]] < dist[u]) u = V[i];
    dist[V[i]] = 10000000;
  }
  dist[u] = 0;
  Q.push(u);
  while (Q.size() > 0) {
    int x = Q.front();
    Q.pop();
    for (int i = (0); i < (G[x].size()); i++) {
      if (dist[G[x][i]] > dist[x] + 1) {
        dist[G[x][i]] = dist[x] + 1;
        Q.push(G[x][i]);
      }
    }
  }
  lp[init] = 0;
  for (int i = (0); i < (V.size()); i++) {
    lp[init] = (((lp[init]) > (dist[V[i]])) ? (lp[init]) : (dist[V[i]]));
  }
  e[init] = (lp[init] + 1) / 2;
}
int main() {
  ios::sync_with_stdio(false);
  for (int i = (1); i < (300100); i++) {
    A[i] = -1;
    dist[i] = 10000000;
  }
  cin >> n >> m >> q;
  int u, v;
  for (int i = (1); i <= (m); i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
    if (findS(u) != findS(v)) {
      unionS(findS(u), findS(v));
    }
  }
  for (int i = (1); i <= (n); i++) {
    if (A[i] < 0) {
      elp(i);
    }
  }
  int op, x, y;
  for (int qq = (1); qq <= (q); qq++) {
    cin >> op;
    if (op == 1) {
      cin >> x;
      cout << lp[findS(x)] << endl;
    } else {
      cin >> x >> y;
      if (findS(x) != findS(y)) {
        x = findS(x);
        y = findS(y);
        lp[x] =
            (((lp[x]) >
              ((((lp[y]) > (e[x] + e[y] + 1)) ? (lp[y]) : (e[x] + e[y] + 1))))
                 ? (lp[x])
                 : ((((lp[y]) > (e[x] + e[y] + 1)) ? (lp[y])
                                                   : (e[x] + e[y] + 1))));
        e[x] = (lp[x] + 1) / 2;
        unionS(x, y);
      }
    }
  }
  return 0;
}
