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 static java.lang.Math.*;

import java.util.*;
import java.io.*;

public class Solution {

    public static int[] find(Pair[] pairs) {
        ArrayList<ArrayList<Integer>> loc = new ArrayList<>();
        for (int i = 0; i <= 500000; i++) {
            loc.add(new ArrayList<>());
        }
        int n = 0;
        for (int i = 0; i < pairs.length; i++) {
            if (pairs[i].type == 1) {
                loc.get(pairs[i].x).add(n++);
            }
            else {
                if (pairs[i].x == pairs[i].y) continue;
                ArrayList<Integer> l1 = loc.get(pairs[i].x);
                ArrayList<Integer> l2 = loc.get(pairs[i].y);
                ArrayList<Integer> com;
                if (l1.size() <= l2.size()) {
                    l2.addAll(l1);
                    l1.clear();
                    com = l2;
                }
                else {
                    l1.addAll(l2);
                    l2.clear();
                    com = l1;
                }
//                System.out.println("common size: " + com.size());
                loc.set(pairs[i].x, new ArrayList<>());
                loc.set(pairs[i].y, com);
            }
        }
//        for (int i = 1; i <= 100000; i++) {
//            if (loc.get(i).size() > 0) System.out.println(i);
//        }

        int[] res = new int[n];
        for (int i = 1; i <= 100000; i++) {
            if (loc.get(i).size() > 0) {
//                System.out.println("reached");
                for (int pos: loc.get(i)) res[pos] = i;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        InputReader fs = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int q = fs.readInt();
        Pair[] pairs = new Pair[q];
        for (int i = 0; i < pairs.length; i++) {
            int type = fs.readInt();
            if (type == 1) {
                pairs[i] = new Pair(type, fs.readInt(), 0);
            }
            else {
                pairs[i] = new Pair(type, fs.readInt(), fs.readInt());
            }
        }
        int[] res = find(pairs);
        for (int i: res) pw.print(i + " ");
        pw.println();

        pw.flush();
        pw.close();
    }
//    static class UF {
//        int[] parent;
//        public UF(int n) {
//            parent = new int[n + 1];
//            for (int i = 1; i < parent.length; i++) {
//                parent[i] = i;
//            }
//        }
//        public void union(int a, int b) {
//            parent[a] = b;
//        }
//        public int find(int a) {
//            while (parent[a] != a) {
//                parent[a] = parent[parent[a]];
//                a = parent[a];
//            }
//            return a;
//        }
//    }
    static class Pair {
        int type; int x; int y;

        public Pair(int type, int x, int y) {
            this.type = type;
            this.x = x;
            this.y = y;
        }
    }
    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public double readDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, readInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
        public int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = readInt();
            }
            return a;
        }
        public int[] readIntArrayShifted(int n) {
            int[] a = new int[n + 1];
            for (int i = 0; i < n; i++) {
                a[i + 1] = readInt();
            }
            return a;
        }
        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = readLong();
            }
            return a;
        }
        public String next() {
            return readString();
        }

        interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

}