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.io.*;
  import java.util.*;
  
  public class Solution {
  
  	static Scanner sc = new Scanner(System.in);
  	// static Reader sc = new Reader();
  	static StringBuilder out = new StringBuilder();
  
  	static String testCase = "Case #";
  	static long mod = 998244353;
  
  	public static void main(String[] args) throws IOException {
  		// TODO Auto-generated method stub
  
  		int t =1;// sc.nextInt();
  
  		int tc = 0;
  
  		while (tc++ < t) {
  
  			Solution run = new Solution();
  
  			run.run();
  		}
  
  		
  		
  		
  		
  		
  		System.out.println(out);
  
  	}
  
  	static ArrayList<Integer> gr[];
  
  	public void run() throws IOException {
  
  
  		
  		int q=sc.nextInt();
  		int par[]=new int[5*(int)1e5+5];
  		
  		for(int i=0;i<par.length;i++)par[i]=i;
  		int qu[][]=new int[q][3];
  		for(int i=0;i<q;i++) {
  			
  			int in=sc.nextInt();
  			qu[i][0]=in;
  			
  			if(in==1) {
  				qu[i][1]=sc.nextInt();
  				
  			}
  			else {
  				
  				int x=sc.nextInt();
  				int y=sc.nextInt();
  				
  				qu[i][1]=x;
  				qu[i][2]=y;
  				
  			}
  		}
  		
  		int ans[]=new int[q];
  		//StringBuilder res= new StringBuilder();
  		ArrayList<Integer> res =new ArrayList<>();
  		for(int i=q-1;i>=0;i--) {
  			
  			
  			int in=qu[i][0];
  			int x=qu[i][1];
  			if(in==1) {
  				
  				ans[i] = par[x];
  				res.add(ans[i]);
  				
  			}else {
  				int y=qu[i][2];
  				par[x] = par[y];
  			}
  		}
  		
  		Collections.reverse(res);
  		for(int i=0;i<res.size();i++)out.append(res.get(i)+" ");
  		//out.append(res.reverse())
  		out.append("\n");
  		
  		
  		
  	
  	}
  	
  	static int getParent(int x,int par[]) {
  		
  		if(x==par[x])return x;
  		
  		return par[par[x]];
  		
  	}
  
  	static int bit[];
  
  	static void modify(int x, int val) {
  
  		for (; x < bit.length; x += (x & -x))
  			bit[x] += val;
  
  	}
  
  	static int get(int x) {
  
  		int sum = 0;
  
  		for (; x > 0; x -= (x & -x))
  			sum += bit[x];
  
  		return sum;
  	}
  
  	static long modInverse(long a, long m) {
  		long m0 = m;
  		long y = 0, x = 1;
  
  		if (m == 1)
  			return 0;
  
  		while (a > 1) {
  			// q is quotient
  			long q = a / m;
  
  			long t = m;
  
  			m = a % m;
  			a = t;
  			t = y;
  
  			// Update x and y
  			y = x - q * y;
  			x = t;
  		}
  
  		// Make x positive
  		if (x < 0)
  			x += m0;
  
  		return x;
  	}
  
  	static class Reader {
  		final private int BUFFER_SIZE = 1 << 16;
  		private DataInputStream din;
  		private byte[] buffer;
  		private int bufferPointer, bytesRead;
  
  		public Reader() {
  			din = new DataInputStream(System.in);
  			buffer = new byte[BUFFER_SIZE];
  			bufferPointer = bytesRead = 0;
  		}
  
  		public Reader(String file_name) throws IOException {
  			din = new DataInputStream(new FileInputStream(file_name));
  			buffer = new byte[BUFFER_SIZE];
  			bufferPointer = bytesRead = 0;
  		}
  
  		public String readLine() throws IOException {
  			byte[] buf = new byte[64]; // line length
  			int cnt = 0, c;
  			while ((c = read()) != -1) {
  				if (c == '\n') {
  					if (cnt != 0) {
  						break;
  					} else {
  						continue;
  					}
  				}
  				buf[cnt++] = (byte) c;
  			}
  			return new String(buf, 0, cnt);
  		}
  
  		public int nextInt() throws IOException {
  			int ret = 0;
  			byte c = read();
  			while (c <= ' ') {
  				c = read();
  			}
  			boolean neg = (c == '-');
  			if (neg)
  				c = read();
  			do {
  				ret = ret * 10 + c - '0';
  			} while ((c = read()) >= '0' && c <= '9');
  
  			if (neg)
  				return -ret;
  			return ret;
  		}
  
  		public long nextLong() throws IOException {
  			long ret = 0;
  			byte c = read();
  			while (c <= ' ')
  				c = read();
  			boolean neg = (c == '-');
  			if (neg)
  				c = read();
  			do {
  				ret = ret * 10 + c - '0';
  			} while ((c = read()) >= '0' && c <= '9');
  			if (neg)
  				return -ret;
  			return ret;
  		}
  
  		public double nextDouble() throws IOException {
  			double ret = 0, div = 1;
  			byte c = read();
  			while (c <= ' ')
  				c = read();
  			boolean neg = (c == '-');
  			if (neg)
  				c = read();
  
  			do {
  				ret = ret * 10 + c - '0';
  			} while ((c = read()) >= '0' && c <= '9');
  
  			if (c == '.') {
  				while ((c = read()) >= '0' && c <= '9') {
  					ret += (c - '0') / (div *= 10);
  				}
  			}
  
  			if (neg)
  				return -ret;
  			return ret;
  		}
  
  		private void fillBuffer() throws IOException {
  			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
  			if (bytesRead == -1)
  				buffer[0] = -1;
  		}
  
  		private byte read() throws IOException {
  			if (bufferPointer == bytesRead)
  				fillBuffer();
  			return buffer[bufferPointer++];
  		}
  
  		public void close() throws IOException {
  			if (din == null)
  				return;
  			din.close();
  		}
  	}
  
  }
  