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 javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import java.awt.*;
import java.awt.desktop.SystemEventListener;
import java.awt.image.AreaAveragingScaleFilter;
import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
import java.math.*;
import java.util.concurrent.locks.ReadWriteLock;


public class Main {

    public static void main(String[] args) throws IOException {
        Reader.init(System.in);
        BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
        int t = Reader.nextInt();
        int k = t;
        ArrayList<Queries> queries = new ArrayList<>();
        int[] currently = new int[500001];
        int i = 0;
        while ( i < currently.length){
            currently[i] = i;
            i++;
        }
        while ( t > 0){
            int q = Reader.nextInt();
            if ( q == 1){
                queries.add(new Queries(1,Reader.nextInt(),-1));
            }
            else{
                queries.add(new Queries(2,Reader.nextInt(),Reader.nextInt()));
            }
            t--;
        }
        i = k-1;
        ArrayList<Integer> ans = new ArrayList<>();
        while ( i >= 0){
            Queries curr = queries.get(i);
            if ( curr.type == 1){
                ans.add(currently[curr.val1]);
            }
            else{
                int cur = currently[curr.val2];
                while ( currently[cur] != cur && cur  != curr.val1){
                    cur =currently[cur];
                }
                currently[curr.val1] = cur;

            }
            i--;
        }
        i = ans.size();
        i--;
        while ( i >= 0){
            int v = ans.get(i);
            output.write(v+" ");
            i--;
        }
        output.write('\n');


        output.flush();


    }
    public static int sub(int a, int b){
       int half = b/2;
       if ( b%2 == 0){
           if ( a < half){
               return 1;
           }
           else{
               return -1;
           }
       }
       else{
           if ( a<= half){
               return 1;
           }
           else{
               return -1;
           }
       }
    }


    private static int bs(int low,int high,int[] array,int find){
        if ( low <= high ){
            int  mid = low + (high-low)/2;
            if ( array[mid] > find){
                high = mid -1;
                return bs(low,high,array,find);
            }
            else if ( array[mid] < find){
                low = mid+1;
                return bs(low,high,array,find);
            }
            return mid;
        }
        return -1;
    }

    private static long max(long a, long b) {
        return  Math.max(a,b);
    }

    private static int min(int a,int b){
        return  Math.min(a,b);
    }

    public static long modularExponentiation(long a,long b,long mod){
        if ( b == 1){
            return a;
        }
        else{
            long ans = modularExponentiation(a,b/2,mod)%mod;
            if ( b%2 == 1){
                return (a*((ans*ans)%mod))%mod;
            }

            return ((ans*ans)%mod);
        }
    }

    public static long sum(long n){
        return  (n*(n+1))/2;
    }
    public static long abs(long a){
        return a < 0 ? (-1*a) : a;
    }
    public static long gcd(long a,long b){
        if ( a == 0){
            return b;
        }
        else{
            return gcd(b%a,a);
        }
    }


}

class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;


    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {

            tokenizer = new StringTokenizer(
                    reader.readLine() );
        }
        return tokenizer.nextToken();
    }

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

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }

    static long nextLong() throws IOException{
        return Long.parseLong(next());
    }
}
/*
class NComparator implements Comparator<Node>{
    @Override
    public int compare(Node o1, Node o2) {
        if ( o2.position > o1.position){
            return 1;
        }
        else if ( o2.position < o1.position){
            return -1;
        }
        else{
            if ( o2.time < o1.time){
                return 1;
            }
            else if ( o2.time > o2.time){
                return -1;
            }
            else{
                return 0;
            }
        }
    }
}


class DComparator implements Comparator<Integer>{
    @Override
    public int compare(Integer o1, Integer o2) {
        if ( o2 > o1){
            return 1;
        }
        else if ( o2 < o1){
            return -1;
        }
        else{
            return 0;
        }
    }
}

*/
class Queries{
    int type;
    int val1;
    int val2;

    Queries(int a,int b,int c){
       type = a;
       val1 = b;
       val2 = c;
    }

}