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.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class ReplacetheNumbers {

	static final String ADD_QUERY = "1";
	static final String REPLACE_QUERY = "2";

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int q = in.nextInt();
		in.nextLine(); // Consume newline left-over

		List<String> queries = new ArrayList<>(q);
		Map<String, List<Integer>> map = new HashMap<>();
		List<String> nums = new ArrayList<>();
		while (q-- > 0) {
			int op = in.nextInt();
			int x = -1;
			int y = -1;
			if (op == 1) {
				x = in.nextInt();
				queries.add(op + " " + x);
			} else {
				x = in.nextInt();
				y = in.nextInt();
				queries.add(op + " " + x + " " + y);
			}

		}
		for (String query : queries) {
			String[] op = query.split(" ");
			switch (op[0]) {
			case ADD_QUERY:
				nums.add(op[1]);
				if (map.get(op[1]) == null) {
					List<Integer> temp = new ArrayList<>();
					temp.add(nums.size() - 1);
					map.put(op[1], temp);
				} else {
					map.get(op[1]).add(nums.size() - 1);
				}
				break;
			case REPLACE_QUERY:
				if (map.get(op[2]) == null) {
					map.put(op[2], new ArrayList<>());
				}
				if (map.containsKey(op[1])) {
					for (int i : map.get(op[1])) {
						nums.set(i, op[2]);
					}
					map.get(op[2]).addAll(new ArrayList<>(map.get(op[1])));
					map.remove(op[1]);
				}
				break;
			}
		}
		StringBuilder sb = new StringBuilder();
		for (String n : nums) {
			sb.append(n + " ");
		}
		System.out.println(sb.toString());
		in.close();
	}

}