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 E_Gardener_and_Tree implements Runnable{

       public static void main(String[] args) throws Exception {
        new Thread(null, new E_Gardener_and_Tree(), "E_Gardener_and_Tree", 1<<28).start();
       }
    public void run(){
         WRITE YOUR CODE HERE!!!!
         JUST WRITE EVERYTHING HERE WHICH YOU WRITE IN MAIN!!!
       }

  }
*/
/////**************************************************************************


public class E_Replace_the_Numbers{
    public static void main(String[] args) {
        FastScanner s= new FastScanner();
        //PrintWriter out=new PrintWriter(System.out);
        //end of program
        //out.println(answer);
        //out.close();
        StringBuilder res = new StringBuilder();
        int q=s.nextInt();
        int pos=0;
        ArrayList<Long> number = new ArrayList<Long>();
        ArrayList<ArrayList<Long>> nice = new  ArrayList<ArrayList<Long>>();
        HashMap<Long,Long> map = new HashMap<Long,Long>();
        HashMap<Long,Long> map2= new HashMap<Long,Long>();
        for(int i=0;i<q;i++){
            int a=s.nextInt();
            if(a==1){
                long num=s.nextLong();
                if(map.containsKey(num)){
                    long yo=map.get(num);
                    nice.get((int)yo).add((long)pos);
                    pos++;
                }
                else{
                    int hh=number.size();
                    number.add(num);
                    ArrayList<Long> well = new  ArrayList<Long>();
                    well.add((long)pos);
                    nice.add(well);
                    map.put(num,(long)hh);
                    pos++;
                }
            }
            else{
                long num1=s.nextLong();
                long num2=s.nextLong();
                if(num1==num2){
                    continue;
                }
                if(map.containsKey(num1)){
                    long hh=map.get(num1);
                    int size1=nice.get((int)hh).size();
                      if(map.containsKey(num2)){
                          long hh2=map.get(num2);
                          int size2=nice.get((int)hh2).size();
                          if(size1<=size2){// size2 will be maintained
                            ArrayList<Long> well= nice.get((int)hh2);
                            ArrayList<Long> give = nice.get((int)hh);
                              for(int k=0;k<give.size();k++){
                                  long b=give.get(k);
                                  well.add(b);
                              }
                              map.remove(num1);
                              map2.put(hh,(long)1);

                               
                          }
                          else{// size1 has to be altered
                            ArrayList<Long> give= nice.get((int)hh2);
                            ArrayList<Long> well = nice.get((int)hh);
                            for(int k=0;k<give.size();k++){
                                long b=give.get(k);
                                well.add(b);
                            }
                            map.remove(num1);
                            map.remove(num2);
                            number.set((int)hh,num2);
                            map.put(num2,hh);
                            map2.put(hh2,(long)1);
                            
                          }
                      }
                      else{
                          number.set((int)hh,num2);
                          map.remove(num1);
                          map.put(num2,hh);

                      }
                }
            }
        }
        long array[]= new long[pos];
        for(int i=0;i<number.size();i++){
           if(!map2.containsKey((long)i)){ 
            long num=number.get(i);
              ArrayList<Long> well = nice.get(i);
                for(int j=0;j<well.size();j++){
                    long kk=well.get(j);
                    array[(int)kk]=num;

                }
            }
        }
        for(int i=0;i<pos;i++){
            res.append(array[i]+" ");
        }
        res.append(" \n");
        System.out.println(res);

    }
    static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
 
		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
 
		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(nextToken());
		}
 
		long nextLong() {
			return Long.parseLong(nextToken());
		}
 
		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}


    static long modpower(long x, long y, long p)
     {
      long res = 1; // Initialize result
   
      x = x % p; // Update x if it is more than or
      // equal to p
   
      if (x == 0)
        return 0; // In case x is divisible by p;
   
      while (y > 0)
      {
   
        // If y is odd, multiply x with result
        if ((y & 1) != 0)
          res = (res * x) % p;
   
        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
      }
      return res;
    }

  
   // SIMPLE POWER FUNCTION=>


      static long power(long x, long y)
        {
            long res = 1;     // Initialize result
        
            while (y > 0)
            {
            
                // If y is odd, multiply x with result
                if ((y & 1) != 0)
                    res = res * x;
        
                // y must be even now
                y = y >> 1; // y = y/2
                x = x * x;  // Change x to x^2
            }
            return res;
        }





}