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.*;
import java.io.*;

public class BearAndElections  {
	// remember long, to reformat ctrl + shift +f
	static Scanner sc = new Scanner(System.in);
	static PrintWriter pw = new PrintWriter(System.out);

 
	public static void main(String[] args) throws Exception {
		  int t=1;
		    while(t-->0) {
		        int q=sc.nextInt();
		        ll arr[]=new ll[5*100000+10];
		        int cnt=0;
		        for(int i=0;i<arr.length;i++)
		        	arr[i]=new ll();
		        for(int i=0;i<q;i++) {
		        	int x=sc.nextInt();
		        	if(x==1) {
		        		int f=sc.nextInt();
		        		if(arr[f]==null)
		        			arr[f]=new ll();
		        		
		        		Node tmp =arr[f].first;
		        		boolean empty = tmp==null;
		        		arr[f].first=new Node(cnt++);
		        		arr[f].first.next=tmp;
		        		if(empty )arr[f].last=arr[f].first;
		        		
		        	}
		        	else {
		        		int occ=sc.nextInt();
		        		int y=sc.nextInt();
		        		if(occ==y)continue;
		        		if(arr[occ]==null || arr[occ].first==null)continue;
		        		if(arr[y]==null)
		        			arr[y]=new ll();
		        		if(arr[y].first==null ) {
		        			arr[y].first=arr[occ].first;
		        			arr[y].last = arr[occ].last;
		        			
		        		}

		        		else{
		        			
		        		arr[y].last.next=arr[occ].first;
		        		}
		        		arr[occ].first= null;
		        	}
		        }
		        int arr2[]=new int[cnt];
		        for(int i=1;i<arr.length;i++) {
		        	ll a = arr[i];
		        	if(a==null )continue;
		        	Node cur = a.first;
		        	while( cur!=null) {
		        		Integer x= cur.data;
		        		if(x!=null);
		        		arr2[x]=i;
		        		cur=cur.next;
		        	}
		        }
		        for(int i=0;i<cnt;i++)
		        	pw.print(arr2[i]+" ");
		     //   pw.println();
		        
		        
		    }
     
		
		
	 pw.close();

	}
	static class Node {
		int data;
		Node next;
		Node prev;
		public Node(int data) {
			this.data=data;
		}
		
	}
	static class ll{
		Node first;
		Node last;
	}

	// --------------------stuff ----------------------
	static class SegmentTree{
		long[]array,sTree;
		int N;
		public SegmentTree(long arr[]) {
			array=arr;
			N=arr.length-1;
			sTree=new long[N<<1];
		}
		void update(int idx){
			array[idx]++;
			idx+=N-1;
			sTree[idx]++;
			while(idx>1) {
				idx>>=1;
			    sTree[idx]++;
			}
			
			
		}
		long query(int l,int r) {
			return query(1,1,N,l,r);
		}
		long query(int node,int s,int e,int l,int r) {
			if(l>e || r<s)return 0;
			if(l<=s && r>=e)return sTree[node];
	       int mid=(s+e)>>1;
	       return query(node<<1,s,mid,l,r)+query(node<<1|1,mid+1,e,l,r);
	
		}
	}
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(FileReader r) {
			br = new BufferedReader(r);
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public long[] nextlongArray(int n) throws IOException {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public Long[] nextLongArray(int n) throws IOException {
			Long[] a = new Long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public int[] nextIntArray(int n) throws IOException {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public Integer[] nextIntegerArray(int n) throws IOException {
			Integer[] a = new Integer[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}

}