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7
2 9 1
2 9 2
 10 5 6
1 2
2 3
2 4
4 5
1 6
2 3 1
2 6 4
2 1 1
1 5
1 6
1 4
 10 6 7
1 2
2 3
1 4
3 5
1 6
5 7
1 1
2 8 10
1 10
2 9 5
1 7
1 4
2 1 9
 100 16 46
36 42
36 50
42 54
42 74
50 58
42 16
50 81
50 96
42 62
54 2
74 75
74 22
2 48
50 95
74 66
75 5
1 62
1 56
2 6 68
1 47
1 43
1 38
1 75
2 22 82
2 56 77
1 71
2 52 15
2 9 1
2 12 59
1 24
2 41 94
2 18 58
2 22 67
1 45
2 68 70
1 81
1 48
1 71
2 76 28
2 31 73
2 58 80
2 100 57
2 88 79
1 30
2 96 23
2 92 44
1 12
1 66
1 24
2 71 68
2 4 4
2 84 43
2 80 15
2 54 13
1 51
2 99 17
1 63
2 12 41
2 1 2
2 62 96
2 79 9
2 59 79
 10 1 9
1 2
1 5
2 7 4
1 4
1 7
2 2 5
2 6 3
1 3
1 4
1 2
 10 5 77
1 2
1 3
3 4
1 5
5 6
1 2
2 3 10
2 5 1
1 2
1 4
2 7 7
2 7 9
1 7
2 4 9
2 2 4
2 3 2
2 5 2
2 10 1
2 3 8
1 9
1 4
1 2
2 8 3
2 8 2
2 2 3
2 5 9
1 10
2 3 10
2 5 9
1 2
1 7
1 4
1 4
1 3
1 4
1 10
2 8 7
1 2
2 3 1
1 10
2 7 7
1 2
1 5
1 3
1 8
2 7 7
1 10
2 4 2
1 9
2 6 6
1 3
1 2
2 8 10
1 1
1 7
2 10 7
1 8
1 9
2 1 4
2 1 1
2 3 3
1 9
1 8
2 9 4
1 4
2 4 4
1 6
2 9 4
2 5 10
1 4
2 8 9
1 10
1 4
1 4
1 10
1 2
1 4
1 7
2 10 8
1 2
2 6 6
2 8 5
 10 4 46
1 2
2 3
1 4
2 5
1 5
1 9
2 6 8
2 10 8
1 1
1 5
1 1
2 6 6
1 8
2 9 3
1 2
1 5
1 2
2 6 5
1 2
1 6
2 5 3
1 5
2 10 5
1 5
2 6 10
2 2 3
2 7 9
2 8 9
1 8
1 3
2 7 1
2 2 2
1 2
1 1
1 5
2 8 7
1 3
1 4
1 3
2 3 1
2 8 8
1 10
1 9
1 10
2 7 10
2 8 9
1 4
2 8 9
1 5
2 6 9
 10 7 26
1 2
2 3
3 4
3 5
4 6
2 7
5 8
2 7 10
1 3
2 8 5
2 9 4
2 5 1
1 5
1 8
1 10
1 3
1 9
1 6
2 1 9
2 5 7
2 1 4
1 6
2 6 7
1 3
1 1
1 3
1 2
2 8 3
2 2 5
1 1
2 7 7
2 5 1
2 1 8
 10 6 21
1 2
2 3
2 4
2 5
4 6
2 7
2 4 1
1 1
2 5 1
1 5
1 3
1 3
1 10
1 5
1 7
1 4
2 6 3
2 7 4
1 10
2 2 5
1 1
1 5
1 8
2 5 7
1 3
2 2 9
1 7

3
0
 2
2
2
 3
0
 4
4
4
0
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
 5
5
5
5
5
5
 4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
 0
9
0
0
 6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
6
 4
4
4
4
 5
0
5
5
 4
4
0
0
0
0
 1
0
0
0
0
1
4
 0
6
1
0
0
1
2
0
0
0
0
6
 5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
5
 3
0
4
 4
4
4
 5
1
5
5
 6
0
0
0
0
6
0
0
0
6
6
0
0
1
6
0
0
0
 0
1
1
1
1
2
 4
4
4
1
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
 3
0
3
3
3
2
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
 4
4
4
4
4
4
4
4
4
4
4
4
4
 3
3
3
3
0
3
3
3
0
3
3
0
3
3

		                                import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.TreeMap;
import java.util.TreeSet;


		    
		    
		    
		                                                public class Solution1 implements Runnable
		                                                {
		                                                    static final long MAX = 464897L;
		                                                    static class InputReader
		                                                    {
		                                                        private InputStream stream;
		                                                        private byte[] buf = new byte[1024];
		                                                        private int curChar;
		                                                        private int numChars;
		                                                        private SpaceCharFilter filter;
		                                                        private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		                                                 
		                                                        public InputReader(InputStream stream)
		                                                        {
		                                                            this.stream = stream;
		                                                        }
		                                                        
		                                                        public int read()
		                                                        {
		                                                            if (numChars==-1) 
		                                                                throw new InputMismatchException();
		                                                            
		                                                            if (curChar >= numChars)
		                                                            {
		                                                                curChar = 0;
		                                                                try 
		                                                                {
		                                                                    numChars = stream.read(buf);
		                                                                }
		                                                                catch (IOException e)
		                                                                {
		                                                                    throw new InputMismatchException();
		                                                                }
		                                                                
		                                                                if(numChars <= 0)                
		                                                                    return -1;
		                                                            }
		                                                            return buf[curChar++];
		                                                        }
		                                                     
		                                                        public String nextLine()
		                                                        {
		                                                            String str = "";
		                                                            try
		                                                            {
		                                                                str = br.readLine();
		                                                            }
		                                                            catch (IOException e)
		                                                            {
		                                                                e.printStackTrace();
		                                                            }
		                                                            return str;
		                                                        }
		                                                        public int nextInt()
		                                                        {
		                                                            int c = read();
		                                                            
		                                                            while(isSpaceChar(c)) 
		                                                                c = read();
		                                                            
		                                                            int sgn = 1;
		                                                            
		                                                            if (c == '-') 
		                                                            {
		                                                                sgn = -1;
		                                                                c = read();
		                                                            }
		                                                            
		                                                            int res = 0;
		                                                            do 
		                                                            {
		                                                                if(c<'0'||c>'9') 
		                                                                    throw new InputMismatchException();
		                                                                res *= 10;
		                                                                res += c - '0';
		                                                                c = read();
		                                                            }
		                                                            while (!isSpaceChar(c)); 
		                                                            
		                                                            return res * sgn;
		                                                        }
		                                                        
		                                                        public long nextLong() 
		                                                        {
		                                                            int c = read();
		                                                            while (isSpaceChar(c))
		                                                                c = read();
		                                                            int sgn = 1;
		                                                            if (c == '-') 
		                                                            {
		                                                                sgn = -1;
		                                                                c = read();
		                                                            }
		                                                            long res = 0;
		                                                            
		                                                            do 
		                                                            {
		                                                                if (c < '0' || c > '9')
		                                                                    throw new InputMismatchException();
		                                                                res *= 10;
		                                                                res += c - '0';
		                                                                c = read();
		                                                            }
		                                                            while (!isSpaceChar(c));
		                                                                return res * sgn;
		                                                        }
		                                                        
		                                                        public double nextDouble() 
		                                                        {
		                                                            int c = read();
		                                                            while (isSpaceChar(c))
		                                                                c = read();
		                                                            int sgn = 1;
		                                                            if (c == '-') 
		                                                            {
		                                                                sgn = -1;
		                                                                c = read();
		                                                            }
		                                                            double res = 0;
		                                                            while (!isSpaceChar(c) && c != '.') 
		                                                            {
		                                                                if (c == 'e' || c == 'E')
		                                                                    return res * Math.pow(10, nextInt());
		                                                                if (c < '0' || c > '9')
		                                                                    throw new InputMismatchException();
		                                                                res *= 10;
		                                                                res += c - '0';
		                                                                c = read();
		                                                            }
		                                                            if (c == '.') 
		                                                            {
		                                                                c = read();
		                                                                double m = 1;
		                                                                while (!isSpaceChar(c)) 
		                                                                {
		                                                                    if (c == 'e' || c == 'E')
		                                                                        return res * Math.pow(10, nextInt());
		                                                                    if (c < '0' || c > '9')
		                                                                        throw new InputMismatchException();
		                                                                    m /= 10;
		                                                                    res += (c - '0') * m;
		                                                                    c = read();
		                                                                }
		                                                            }
		                                                            return res * sgn;
		                                                        }
		                                                        
		                                                        public String readString() 
		                                                        {
		                                                            int c = read();
		                                                            while (isSpaceChar(c))
		                                                                c = read();
		                                                            StringBuilder res = new StringBuilder();
		                                                            do 
		                                                            {
		                                                                res.appendCodePoint(c);
		                                                                c = read();
		                                                            } 
		                                                            while (!isSpaceChar(c));
		                                                            
		                                                            return res.toString();
		                                                        }
		                                                     
		                                                        public boolean isSpaceChar(int c) 
		                                                        {
		                                                            if (filter != null)
		                                                                return filter.isSpaceChar(c);
		                                                            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		                                                        }
		                                                     
		                                                        public String next() 
		                                                        {
		                                                            return readString();
		                                                        }
		                                                        
		                                                        public interface SpaceCharFilter 
		                                                        {
		                                                            public boolean isSpaceChar(int ch);
		                                                        }
		                                                    }
		                                                     
		                                                    public static void main(String args[]) throws Exception
		                                                    {
		                                                        new Thread(null, new Solution1(),"Solution",1<<26).start();
		                                                    }   
		                                                    static int gcd(int a, int b) 
		                                                    { 
		                                                      if (b == 0) 
		                                                        return a; 
		                                                      return gcd(b, a % b);  
		                                                    } 
		                                                    
		                                                    long MOD = 1000000007;
		                                                    
		                                                    ArrayList<Integer> adj[];
		                                                    ArrayList<Pair> adj2[];
		                                                    public void run() 
		                                                    {
		                                                        
		                                                            //InputReader sc= new InputReader(new FileInputStream("input.txt"));
		                                                            //PrintWriter w= new PrintWriter(new FileWriter("output.txt"));
		                                                            InputReader sc = new InputReader(System.in);
		                                                            PrintWriter w = new PrintWriter(System.out);
		                                                            int n = sc.nextInt();
		                                                            int m = sc.nextInt();
		                                                            int q = sc.nextInt();
		                                                            arr = new int[n];
		                                                            dia = new int[n];
		                                                            adj = new ArrayList[n];
		                                                            size = new int[n];
		                                                            for(int i = 0;i < n;i++) {
		                                                            	arr[i] = i;
		                                                            	dia[i] = 0;
		                                                            	size[i] = 1;
		                                                            	adj[i] = new ArrayList();
		                                                            }
		                                                            for(int i = 0;i < m;i++) {
		                                                            	int a = sc.nextInt()-1;
		                                                            	int b = sc.nextInt()-1;
		                                                            	adj[a].add(b);
		                                                            	adj[b].add(a);
		                                                            	union(a,b,1);
		                                                            }
		                                                            visit = new boolean[n];
		                                                            for(int i = 0;i < n;i++) {
		                                                            	if(!visit[i]) {
		                                                            		max = 0;
		                                                            		ver = -1;
		                                                            		int ans1 = bfs(i);
		                                                            		max = 0;
		                                                            		if(ver != -1) {
		                                                            			int ans2 = bfs(ver);
		                                                            			dia[root(i)] = ans2;
		                                                            		}
		                                                            		
		                                                            		
		                                                            	}
		                                                            }
		                                                            while(q-- > 0) {
		                                                            	int x = sc.nextInt();
		                                                            	if(x == 2) {
		                                                            		int a = sc.nextInt()-1;
		                                                            		int b = sc.nextInt()-1;
		                                                            		if(find(a,b)) {
		                                                            			continue;
		                                                            		}
		                                                            		union(a,b,2);
		                                                            	}else {
		                                                            		int a = sc.nextInt()-1;
		                                                            		w.println(dia[root(a)]);
		                                                            	}
		                                                            }
		                                                            w.close();
		                                                     }
		                                                    int[] arr;
		                                                    int[] dia;
		                                                    int[] size;
		                                                    boolean[] visit;
		                                                    int root(int a) {
		                                                    	while(arr[a] != a) {
		                                                    		arr[a] = arr[arr[a]];
		                                                    		a = arr[a];
		                                                    	}
		                                                    	return a;
		                                                    }
		                                                    int ver = -1;
		                                                    int max = 0;
		                                                    int bfs(int a) {
		                                                    	visit[a] = true;
		                                                    	TreeSet<Integer> visited = new TreeSet();
		                                                    	TreeMap<Integer,Integer> level = new TreeMap();
		                                                    	visited.add(a);
		                                                    	Queue<Integer> q = new LinkedList();
		                                                    	level.put(a,0);
		                                                    	q.add(a);
		                                                    	while(!q.isEmpty()) {
		                                                    		int x = q.poll();
		                                                    		Iterator<Integer> it = adj[x].iterator();
		                                                    		while(it.hasNext()) {
		                                                    			int temp = it.next();
		                                                    			if(!visited.contains(temp)) {
		                                                    				level.put(temp,level.get(x) + 1);
		                                                    				if(max <= level.get(temp)) {
		                                                    					max=  level.get(temp);
		                                                    					ver = temp;
		                                                    					
		                                                    				}
		                                                    				visit[temp] = true;
		                                                    				visited.add(temp);
		                                                    				q.add(temp);
		                                                    			}
		                                                    		}
		                                                    		
		                                                    	}
		                                                    	return max;
		                                                    }
		                                                    void union(int x,int y,int val) {
		                                                    	int roota = root(x);
		                                                    	int rootb=  root(y);
		                                                    	if(size[roota] < size[rootb]) {
		                                                    		arr[roota] = rootb;
		                                                    		size[rootb] += size[roota];
		                                                    	}else {
		                                                    		arr[rootb] = arr[roota];
		                                                    		size[roota] += size[rootb];
		                                                    	}
		                                                    	
		                                                    	if(val != 1)
		                                                    	dia[rootb] = Math.max(dia[roota],Math.max(dia[rootb],(dia[roota] + 1)/2 + (dia[rootb] + 1)/2 + 1));
		                                                    }
		                                                    boolean find(int a,int b) {
		                                                    	if(root(a) == root(b)) {
		                                                    		return true;
		                                                    	}
		                                                    	return false;
		                                                    }
		                                                    class Pair implements Comparable<Pair>{
		                                                        long a;
		                                                        int b;
		                                                        //int c;
		                                                        Pair(long a,int b){
		                                                            this.b = b;
		                                                            this.a = a;
		                                                        }
		                                                        public boolean equals(Object o) {
		                                                            Pair p = (Pair)o;
		                                                            return this.a == p.a && this.b == p.b;
		                                                        }
		                                                        public int hashCode(){
		                                                            return Long.hashCode(a)*27 + Long.hashCode(b)* 31;
		                                                        }
		                                                        public int compareTo(Pair p) {
		                                                            return Long.compare(this.a,p.a);
		                                                        }
		                                                    }
		                                    }