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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Objects;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        EReplaceTheNumbers solver = new EReplaceTheNumbers();
        solver.solve(1, in, out);
        out.close();
    }

    static class EReplaceTheNumbers {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int q = in.nextInt();
            ArrayList<Pair> queries = new ArrayList<>();
            dsu uf = new dsu(500005);
            int last = -1;
            for (int i = 0; i < q; i++) {
                int t = in.nextInt();
                if (t == 1) {
                    int x = in.nextInt();
//                uf.sz[x]++;
                    queries.add(new Pair(1, x, 0));
                } else {
                    last = i;
                    int x = in.nextInt(), y = in.nextInt();
//                uf.merge(y,x);
                    queries.add(new Pair(2, x, y));
                }
            }
            ArrayList<Integer> ans = new ArrayList<>();
            for (int i = q - 1; i >= 0; i--) {
                Pair p = queries.get(i);
                if (p.a == 1) {
                    ans.add(uf.find(p.b));
                } else {
                    uf.merge(p.c, p.b);
//                out.println(i,uf.find(p.b));
                }
            }
//        for(int i=0;i<=last;i++){
//            Pair p= queries.get(i);
//            if(p.a==2) continue;
//            int par= uf.find(p.b);
//            ans.add(par);
//        }
//        for(int i=last+1;i<q;i++){
//            Pair p= queries.get(i);
//            ans.add(p.b);
//        }
            Collections.reverse(ans);
            for (int a : ans) out.print(a + " ");
            out.println();

        }

        class Pair {
            int a;
            int b;
            int c;

            Pair(int a, int b, int c) {
                this.a = a;
                this.b = b;
                this.c = c;
            }

            public int hashCode() {
                return Objects.hash(a, b);
            }

            public boolean equals(Object obj) {
                Pair that = (Pair) obj;
                return a == that.a && b == that.b;
            }

            public String toString() {
                return "[" + a + ", " + b + "]";
            }

        }

        class dsu {
            private int size;
            private int[] sz;
            private int[] par;
            private int numComponents;

            public dsu(int size) {

                this.size = numComponents = size;
                sz = new int[size];
                par = new int[size];
                clear();
            }

            public int find(int p) {
                if (p == par[p]) return p;
                return par[p] = find(par[p]);
            }

            public void merge(int p, int q) {
                int root1 = find(p);
                int root2 = q;
//            if (root1 == root2) return;
//            sz[root1] += sz[root2];
                par[root2] = root1;
                numComponents--;
            }

            public void clear() {
                for (int i = 0; i < size; i++) {
                    par[i] = i;
                    sz[i] = 1;
                }
            }

        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println() {
            writer.println();
        }

        public void close() {
            writer.close();
        }

    }
}

