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.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.HashMap;

@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 {
		Reader fs = new Reader();
		PrintWriter pw = new PrintWriter(System.out);
		int q = fs.nextInt();
		HashMap<Integer, link>ans = new HashMap<>();
		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) {
						connect(temp1.head , temp.head);
					}
					else {
						connect(temp1.tail, temp.head);
					}
					if(temp.tail == null) {
						temp1.tail = temp.head;
					}
					else {
						temp1.tail = temp.tail;
					}
				}
				ans.remove(x);
			}
		}
		int fin[] = new int[cnt];
		for(int x : ans.keySet()) {
			Node he = ans.get(x).head;
			while(he != null) {
				fin[he.data] = x;
				he = he.next;
			}
		}
		for(int x : fin)
		pw.print(x + " ");
		pw.println();
		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 {
		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 next() throws IOException {
			byte[] buf = new byte[100009];
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c <= ' ') {
					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 int[] readArray(int n) throws IOException {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}
 
		public int[] readArray(int n, int x) throws IOException {
			int[] arr = new int[n + x];
			for (int i = x; i < n + x; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}
 
		public ArrayList<Integer> readList(int n) throws IOException {
			ArrayList<Integer> a = new ArrayList<Integer>();
			for (int i = 0; i < n; i++) {
				a.add(nextInt());
			}
			return a;
		}
 
		public int[][] read2Array(int n, int m) throws IOException {
			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;
		}
 
		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}
	}
}
