#include <bits/stdc++.h>   using namespace std;   const int Maxn = 4e5;   int n, m, q;   int head[Maxn], tot, father[Maxn], cnt[Maxn];   int vis[Maxn];   struct Edge {     int to, next;   } edge[Maxn * 10];   void init() {     memset(head, -1, sizeof(head));     tot = 0;     for (int i = 0; i < Maxn; i++) father[i] = i;   }   int Find(int x) {     int y = x;     while (y != father[y]) {       y = father[y];     }     while (x != father[x]) {       int temp = father[x];       father[x] = y;       x = temp;     }     return y;   }   void Union(int a, int b) {     int ra = Find(a), rb = Find(b);     if (ra == rb) return;     father[ra] = rb;     cnt[rb] =         max((cnt[ra] + 1) / 2 + (cnt[rb] + 1) / 2 + 1, max(cnt[ra], cnt[rb]));     cnt[ra] = 0;   }   void add_edge(int u, int v) {     edge[tot].to = v;     edge[tot].next = head[u];     head[u] = tot++;   }   int pos, len;   void dfs(int u, int deep, int tar) {     if (vis[u] == tar) return;     vis[u] = tar;     if (deep > len) {       len = deep;       pos = u;     }     for (int i = head[u]; ~i; i = edge[i].next) {       int v = edge[i].to;       dfs(v, deep + 1, tar);       Union(u, v);     }   }   int process(int u) {     pos = len = -1;     dfs(u, 0, 1);     dfs(pos, 0, 2);     return len;   }   int main() {     init();     scanf( %d %d %d , &n, &m, &q);     while (m--) {       int u, v;       scanf( %d %d , &u, &v);       add_edge(u, v);       add_edge(v, u);     }     for (int i = 1; i <= n; i++) {       if (vis[i]) continue;       int Root = Find(i);       cnt[Root] = process(i);     }     while (q--) {       int op;       scanf( %d , &op);       if (op == 1) {         int u;         scanf( %d , &u);         printf( %d n , cnt[Find(u)]);       } else {         int u, v;         scanf( %d %d , &u, &v);         Union(u, v);       }     }     return 0;   }   