description: You have an array of integers (initially empty).
  
  You have to perform q queries. Each query is of one of two types: 
  
    * "1 x" — add the element x to the end of the array; 
    * "2 x y" — replace all occurrences of x in the array with y. 
  
  
  
  Find the resulting array after performing all the queries.
  
  Input
  
  The first line contains a single integer q (1 ≤ q ≤ 5 ⋅ 10^5) — the number of queries.
  
  Next q lines contain queries (one per line). Each query is of one of two types: 
  
    * "1 x" (1 ≤ x ≤ 5 ⋅ 10^5); 
    * "2 x y" (1 ≤ x, y ≤ 5 ⋅ 10^5). 
  
  
  
  It's guaranteed that there is at least one query of the first type.
  
  Output
  
  In a single line, print k integers — the resulting array after performing all the queries, where k is the number of queries of the first type.
  
  Examples
  
  Input
  
  
  7
  1 3
  1 1
  2 1 2
  1 2
  1 1
  1 2
  2 1 3
  
  
  Output
  
  
  3 2 2 3 2 
  
  Input
  
  
  4
  1 1
  1 2
  1 1
  2 2 2
  
  
  Output
  
  
  1 2 1 
  
  Input
  
  
  8
  2 1 4
  1 1
  1 4
  1 2
  2 2 4
  2 4 3
  1 2
  2 2 7
  
  
  Output
  
  
  1 3 3 7 
  
  Note
  
  In the first example, the array changes as follows:
  
  [] → [3] → [3, 1] → [3, 2] → [3, 2, 2] → [3, 2, 2, 1] → [3, 2, 2, 1, 2] → [3, 2, 2, 3, 2].
  
  In the second example, the array changes as follows:
  
  [] → [1] → [1, 2] → [1, 2, 1] → [1, 2, 1].
  
  In the third example, the array changes as follows:
  
  [] → [] → [1] → [1, 4] → [1, 4, 2] → [1, 4, 4] → [1, 3, 3] → [1, 3, 3, 2] → [1, 3, 3, 7].
solution: 
  import java.util.*;
  
  import java.io.*;
  import java.math.BigInteger;
  import java.nio.charset.StandardCharsets;
  	
  public class Main {
  		private static FS sc = new FS();
  		
  		private static class FS {
  			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  			StringTokenizer st = new StringTokenizer("");
  			String next() {
  				while (!st.hasMoreTokens())
  					try {
  						st=new StringTokenizer(br.readLine());				               
  		            } catch (IOException e) {}
  				return st.nextToken();
  			}
  			
  			int nextInt() {
  				return Integer.parseInt(next());
  			}
  			long nextLong() {
  				return Long.parseLong(next());
  			}
  		}
  		
  		private static class extra {
  			
  			static int[] intArr(int size) {
  				int[] a = new int[size];
  				for(int i = 0; i < size; i++) a[i] = sc.nextInt();
  				return a;
  			}
  			
  			static long[] longArr(int size) {
  				Scanner scc = new Scanner(System.in);
  				long[] a = new long[size];
  				for(int i = 0; i < size; i++) a[i] = sc.nextLong();
  				return a;
  			}
  			
  			static long intSum(int[] a) {
  				long sum = 0; 
  				for(int i = 0; i < a.length; i++) {
  					sum += a[i];
  				}
  				return sum;
  			}
  			
  			static long longSum(long[] a) {
  				long sum = 0; 
  				for(int i = 0; i < a.length; i++) {
  					sum += a[i];
  				}
  				return sum;
  			}
  			
  			static LinkedList[] graphD(int vertices, int edges) {
  				LinkedList<Integer>[] temp = new LinkedList[vertices+1];
  				for(int i = 0; i <= vertices; i++) temp[i] = new LinkedList<>();
  				for(int i = 0; i < edges; i++) {
  					int x = sc.nextInt();
  					int y = sc.nextInt();
  					temp[x].add(y);
  				}
  				return temp;
  			}
  			
  			static LinkedList[] graphUD(int vertices, int edges) {
  				LinkedList<Integer>[] temp = new LinkedList[vertices+1];
  				for(int i = 0; i <= vertices; i++) temp[i] = new LinkedList<>();
  				for(int i = 0; i < edges; i++) {
  					int x = sc.nextInt();
  					int y = sc.nextInt();
  					temp[x].add(y);
  					temp[y].add(x);
  				}
  				return temp;
  			}
  			
  			static void printG(LinkedList[] temp) {
  				for(LinkedList<Integer> aa:temp) System.out.println(aa);
  			}
  			
  			static long cal(long val, long pow, long mod) {
  				if(pow == 0) return 1;
  				long res = cal(val, pow/2, mod);
  				
  				long ret = (res*res)%mod;
  				if(pow%2 == 0) return ret;
  				return (val*ret)%mod;
  			}
  			
  			static long gcd(long a, long b) { return b == 0 ? a:gcd(b, a%b); }
  			
  		}
  		
  		static int mod = (int) 1e9;
  		
  		static LinkedList<Integer>[] temp, idx;
  		static long inf = (long) Long.MAX_VALUE;
  //		static long inf = Long.MAX_VALUE;
  //		static int max;
  		
  		public static void main(String[] args) { 
  //			int t = sc.nextInt();
  			int t = 1;
  			StringBuilder ret = new StringBuilder();
  			while(t-- > 0) {
  				int n = sc.nextInt();
  				int[][] a = new int[n][3];
  				int[] replace = new int[(int) 5e5 + 100];
  				for(int i = 0; i < replace.length; i++) replace[i] = i; 
  				for(int i = 0; i < n; i++) {
  					int whatToDo = sc.nextInt();
  					a[i][0] = whatToDo;
  					if(whatToDo == 1) {
  						a[i][1] = sc.nextInt();
  						a[i][2] = -1;
  					} else {
  						a[i][1] = sc.nextInt();
  						a[i][2] = sc.nextInt();
  					}
  				}
  				ArrayList<Integer> ans = new ArrayList<>();
  				for(int i = n-1; i >= 0; i--) {
  					if(a[i][0] == 2) replace[a[i][1]] = replace[a[i][2]];
  					else ans.add(replace[a[i][1]]);
  				}
  				Collections.reverse(ans);
  				for(int aa:ans) ret.append(aa + " ");
  			}
  			System.out.println(ret);
  		}
  
  	}
  
  	
  	
  
  
  	
  	
  	
  