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.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
public class Main {
	public static void main(String[]args) throws IOException {
		new Main().run();
	}
	File input=new File("D:\\test\\input.txt");
	void run() throws IOException{
//	  new solve().setIO(input, System.out).run();
		new solve().setIO(System.in, System.out).run();
	}
	class solve extends ioTask{
		int n,k,i,j,len,op,a,b;
		int[]son=new int[500005],fa,v;
		int f(int a) {
			if(fa[a]==0)return fa[a]=a;
			if(fa[a]==a)return fa[a];
			return fa[a]=f(fa[a]);
		}
		void run() throws IOException {
			n=in.in();
			fa=new int[n+1];
			v=new int[n+1];
			len=1;
			while(n-->0) {
				op=in.in();
				a=in.in();
				if(op==1) {
					if(son[a]==0) {
						son[a]=len;
						fa[len]=len;
						v[len]=a;
						len++;
					}
					else{
						fa[len]=son[a];
						v[len]=a;
						len++;
					}
				}else {
					b=in.in();
					if(a==b)continue;
					if(son[a]==0)continue;
					if(son[b]==0) {
						v[f(son[a])]=b;
						son[b]=son[a];
						son[a]=0;
					}else {
						fa[f(son[a])]=son[b];
						son[a]=0;
					}
				}
			}

			for(i=1;i<len;i++) {
				out.print(v[f(i)]+" ");
			}
			out.println();
			out.close();
		}
	}
	class In{
		private StringTokenizer in=new StringTokenizer("");
		private InputStream is;
		private BufferedReader bf;
		public In(File file) throws IOException {
			is=new FileInputStream(file);
			init();
		}
		public In(InputStream is) throws IOException
		{
			this.is=is;
			init();
		}
		private void init() throws IOException {
			bf=new BufferedReader(new InputStreamReader(is));
		}
		boolean hasNext() throws IOException {
			return in.hasMoreTokens()||bf.ready();
		}
		String ins() throws IOException {
			while(!in.hasMoreTokens()) {
				in=new StringTokenizer(bf.readLine());
			}
			return in.nextToken();
		}
		int in() throws IOException {
			return Integer.parseInt(ins());
		}
		long inl() throws IOException {
			return Long.parseLong(ins());
		}
		double ind() throws IOException {
			return Double.parseDouble(ins());
		}
	}
	class Out{
		PrintWriter out;
		private OutputStream os;
		private void init() {
			out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(os)));
		}
		public Out(File file) throws IOException {
			os=new FileOutputStream(file);
			init();
		}
		public Out(OutputStream os) throws IOException
		{
			this.os=os;
			init();
		}
	}
	class graph{
		int[]to,nxt,head;
		int cnt;
		void init(int n) {
			cnt=1;
			for(int i=1;i<=n;i++)
			{
				head[i]=0;
			}
		}
		public graph(int n,int m) {
			to=new int[m+1];
			nxt=new int[m+1];
			head=new int[n+1];
			cnt=1;
		}
		void add(int u,int v) {
			to[cnt]=v;
			nxt[cnt]=head[u];
			head[u]=cnt++;
		}
	}
 
	abstract class ioTask{
		In in;
		PrintWriter out;
		public ioTask setIO(File in,File out) throws IOException{
			this.in=new In(in);
			this.out=new Out(out).out;
			return this;
		}
		public ioTask setIO(File in,OutputStream out) throws IOException{
			this.in=new In(in);
			this.out=new Out(out).out;
			return this;
		}
		public ioTask setIO(InputStream in,OutputStream out) throws IOException{
			this.in=new In(in);
			this.out=new Out(out).out;
			return this;
		}
		public ioTask setIO(InputStream in,File out) throws IOException{
			this.in=new In(in);
			this.out=new Out(out).out;
			return this;
		}
		void run()throws IOException{
			 
		}
	}
}