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].
1
1 50
 1
1 114514
 1
1 2002
 1
1 500

50 
 114514 
 2002 
 500 

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeMap;

import static java.lang.Math.min;
import static java.lang.Math.max;
import static java.lang.Math.abs;

@SuppressWarnings("unused")
public class D {
	static boolean DEBUG = false;
	static final int maxxi = 5 * (int) 1e5 + 5;

	public static void main(String[] args) throws IOException {
		Instant start = Instant.now();
		if (args.length == 2) {
			System.setIn(new FileInputStream(new File("D:\\program\\javaCPEclipse\\CodeForces\\src\\input.txt")));
			// System.setOut(new PrintStream(new File("output.txt")));
			System.setErr(new PrintStream(new File("D:\\program\\javaCPEclipse\\CodeForces\\src\\error.txt")));
			DEBUG = true;
		}
		Reader fs = new Reader();
		PrintWriter pw = new PrintWriter(System.out);
//		link s = new link(1);
//		s.add(2);
//		s.add(3);
//		s.add(0);
//		s.add(-9);
//		Node he = s.head;
//		while(he != null) {
//			pw.print(he.data + " ")
//			;
//			he = he.next;
//		}
//		pw.println();
//		pw.println(s.head.data + " " + s.tail.data);
		int q = fs.nextInt();
//		pw.println(maxxi);
//		link ans[] = new link[maxxi];
//		for(int i = 0 ; i < maxxi ; i++) {
//			ans[i] = new link();
//		}
		TreeMap<Integer, link>ans = new TreeMap<>();
		int cnt = 0;
		for (int i = 0; i < q; i++) {
			int c = fs.nextInt();
			if (c == 1) {
				int x = fs.nextInt();
				if (ans.get(x) == null) {
					ans.put(x, new link(cnt++));
				} else {
					ans.get(x).add(cnt++);
				}
			} else {
				
				int x = fs.nextInt(), y = fs.nextInt();
				if(x == y) {
					continue;
				}
				if(ans.get(x) == null) {
					continue;
				}
				link temp = ans.get(x);
				link temp1 = ans.get(y);
				if(temp1 == null) {
					ans.put(y, temp);
				}
				else {
					if(temp1.tail == null) {
//						System.out.println(x + " " + y);
//						System.out.println(ans);
						connect(temp1.head , temp.head);
					}
					else {
						connect(temp1.tail, temp.head);
					}
					if(temp.tail == null) {
						temp1.tail = temp.head;
					}
					else {
						temp1.tail = temp.tail;
					}
//					pw.println(temp1);
				}
				ans.remove(x);
//				ans[x] = new link();
			}
		}
//		for (int i = 0; i <= 7; i++) {
//			pw.println(i + " " + ans[i]);
//		}
		int fin[] = new int[cnt];
		for(int x : ans.keySet()) {
			StringTokenizer st = new StringTokenizer(ans.get(x).toString());
			while(st.hasMoreTokens()) {
				Integer temp = Integer.parseInt(st.nextToken());
				fin[temp] = x;
			}
		}
		for(int x : fin)
		pw.print(x + " ");
		pw.println();
		Instant end = Instant.now();
		if (DEBUG) {
			pw.println(Duration.between(start, end));
		}
		pw.close();
	}
	
	static class link {
		Node tail;
		Node head;
		
		link(int data) {
			head = new Node(data);
			tail = head.next;
		}
		
		link() {
			
		}
		
		void add(int e) {
			if (head.next == null) {
				head.next = new Node(e);
				head.next.prev = head;
				tail = head.next;
			} else {
				tail.next = new Node(e);
				tail.next.prev = tail;
				tail = tail.next;
			}
		}
		
		public String toString() {
			StringBuilder sb = new StringBuilder();
			Node he = this.head;
			while(he != null) {
				sb.append(he.data + " ");
				he = he.next;
			}
			return sb.toString();
		}
	}

	static class Node {
		Node prev, next;
		int data;

		public Node(int data) {
			this.data = data;
		}
	}
	
	static void connect(Node x, Node y) {
		x.next = y;
		y.prev = x;
	}

	public static void print(long a, long b, long c, PrintWriter pw) {
		pw.println(a + " " + b + " " + c);
		return;
	}

	static class Reader {
		BufferedReader br;
		StringTokenizer st;

		public Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		int[] readArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		int[][] read2Array(int n, int m) {
			int a[][] = new int[n][m];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					a[i][j] = nextInt();
				}
			}
			return a;
		}
	}
}
