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.Collections;
import java.util.HashMap;
import java.util.Scanner;

public class ReplacetheNumbers {
	public static void solve(ArrayList<ArrayList<Integer>> arr,int q) {
		HashMap<Integer, Integer> map=new HashMap<Integer, Integer>();
		for(ArrayList<Integer> al:arr) {
			if(al.size()==2) {
				map.put(al.get(1), al.get(1));
			}
			else {
				map.put(al.get(1), al.get(1));
				map.put(al.get(2), al.get(2));
			}
		}
//		System.out.println(map);
		ArrayList<Integer> res=new ArrayList<Integer>();
		for (int i = arr.size()-1; i >=0; i--) {
			ArrayList<Integer> x=arr.get(i);
			if(x.get(0)==1) {
				res.add(map.get(x.get(1)));
			}
			else {
				map.put(x.get(1), x.get(2));
			}
		}
		Collections.reverse(res);
		for (int i = 0; i < res.size(); i++) {
			System.out.print(res.get(i)+" ");
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);
		int q=in.nextInt();
		ArrayList<ArrayList<Integer>> arr=new ArrayList<>();
		for (int i = 0; i < q; i++) {
			int x=in.nextInt();
			if(x==1) {
				arr.add(new ArrayList<>());
				arr.get(arr.size()-1).add(x);
				arr.get(arr.size()-1).add(in.nextInt());
			}
			else {
				arr.add(new ArrayList<>());
				arr.get(arr.size()-1).add(x);
				arr.get(arr.size()-1).add(in.nextInt());
				arr.get(arr.size()-1).add(in.nextInt());
			}
		}
		solve(arr, q);
//		System.out.println(arr);
	}

}
