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.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.*;

public class Mainnn {

    static final File ip = new File("input.txt");
    static final File op = new File("output.txt");
    static {
        try {
            System.setOut(new PrintStream(op));
            System.setIn(new FileInputStream(ip));
        } catch (Exception e) {
        }

        // in = new InputReader(System.in);
    }

    private static final PrintWriter out = new PrintWriter(System.out);

    static boolean isVowel(char ch) {
        if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
            return true;
        return false;
    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        // out = new PrintWriter(new BufferedOutputStream(System.out));

        // out.println(result); // print via PrintWriter
        /////////////////////////////////////////////
        int test = 1;
        // int test = sc.nextInt();
        while (test-- > 0) {
            ArrayList<int[]> as = new ArrayList<>();
            int[] cnt = new int[500000 + 10];
            for (int i = 0; i < cnt.length; i++)
                cnt[i] = i;
            int n = sc.nextInt();
            for (int i = 0; i < n; i++) {
                int x = sc.nextInt();
                if (x == 1) {
                    int y = sc.nextInt();
                    as.add(new int[] { x, y });
                } else {
                    int y = sc.nextInt();
                    int z = sc.nextInt();
                    as.add(new int[] { x, y, z });
                }
            }
            ArrayList<Integer> ans = new ArrayList<>();
            for (int i = n - 1; i >= 0; i--) {
                if (as.get(i).length == 2) {
                    ans.add(cnt[as.get(i)[1]]);
                } else {
                    cnt[as.get(i)[1]] = cnt[as.get(i)[2]];
                }
            }
            Collections.reverse(ans);
            for (int i = 0; i < ans.size(); i++)
                out.print(ans.get(i) + " ");
            out.println();
        }
        ///////////////////////////////////////
        out.close();

    }

    static long power(long x, long y, long p) {
        long res = 1;
        x = x % p;
        if (x == 0)
            return 0;
        while (y > 0) {
            if ((y & 1) != 0)
                res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }

    static void sortI(int[] arr) {
        int n = arr.length;
        Random rnd = new Random();
        for (int i = 0; i < n; ++i) {
            int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n - i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
        Arrays.sort(arr);
    }

    static void sortL(long[] arr) {
        int n = arr.length;
        Random rnd = new Random();
        for (int i = 0; i < n; ++i) {
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(n - i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
        Arrays.sort(arr);
    }

    private static long gcd(long a, long b) {
        return (a == 0 ? b : gcd(b % a, a));
    }

    static class pair {
        int a;
        int b;

        pair(int x, int y) {
            this.a = x;
            this.b = y;
        }

        // public int compare(pair p1, pair p2) {
        // if (p1.a > p2.a)
        // return 1;
        // else if (p1.a < p2.a)
        // return -1;
        // return 0;
        // }
    }

    static class first implements Comparator<pair> {

        public int compare(pair p1, pair p2) {
            if (p1.a > p2.a)
                return -1;
            else if (p1.a < p2.a)
                return 1;
            return 0;
        }
    }

    static class second implements Comparator<pair> {

        public int compare(pair p1, pair p2) {
            if (p1.b > p2.b)
                return 1;
            else if (p1.b < p2.b)
                return -1;
            return 0;
        }
    }

    // -----------PrintWriter for faster output---------------------------------

    // -----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
    // --------------------------------------------------------
}