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

public class E {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int q = sc.nextInt();
        HashMap<Integer, Integer>a = new HashMap<>();
        StringBuilder sb = new StringBuilder();
        ArrayList<String>qu=  new ArrayList<>();
        while(q-->0){
            qu.add(sc.nextLine());
        }
        for(int i =qu.size()-1;i>=0;i--){
            String [] tmp = qu.get(i).split(" ");
            if(tmp[0].equals("2")){
                if(a.containsKey(Integer.parseInt(tmp[2]))){
                    a.put(Integer.parseInt(tmp[1]),a.get(Integer.parseInt(tmp[2])));
                }
                else
                a.put(Integer.parseInt(tmp[1]),Integer.parseInt(tmp[2]));

            }else{
                if (a.containsKey(Integer.parseInt(tmp[1]))){
                    sb.append(a.get(Integer.parseInt(tmp[1]))+" ");
                }else{
                    sb.append(tmp[1]+" ");
                }
            }
        }
        pw.println(sb.reverse().toString());
        pw.close();

//        // -------------------------------------------------------------- TLE SOLUTION ----------------------------------------------------------------------------
//        int i =0; // index of the element in tha array
//        while(q-->0){
//            int t = sc.nextInt();
//            if(t==1){
//                int v = sc.nextInt();
//                if(a.containsKey(v)){
//                    ArrayList<Integer>tmp = a.get(v);
//                    tmp.add(i);
//                    a.put(v,tmp);
//                }else{
//                    ArrayList<Integer>tmp = new ArrayList<>();
//                    tmp.add(i);
//                    a.put(v,tmp);
//                }
//                i++;
//            }else{
//                int x = sc.nextInt();
//                int y = sc.nextInt();
//                if(a.containsKey(x)){
//                    ArrayList<Integer>tmp = a.get(x);
//                    a.remove(x);
//                    if(a.containsKey(y)){
//                        ArrayList<Integer>yy= a.get(y);
//                        for(int k=0;k<yy.size();k++){
//                            tmp.add(yy.get(k));
//                        }
//                    }
//                    a.put(y,tmp);
//                }
//            }
//        }
//        int [] res = new int [i];
//        for(Integer key : a.keySet()){
//            ArrayList<Integer>tmp = a.get(key);
//            for(int j =0;j<tmp.size();j++){
//                res[tmp.get(j)]=key;
//            }
//        }
//
//        for(int k=0;k<res.length;k++){
//            pw.print(res[k]+" ");
//        }
////        pw.println(Arrays.toString(res));
//        pw.close();

    }
    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();
        }
    }
}
