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

public class Practice {
	static boolean multipleTC = false;
	FastReader in;
	PrintWriter out;

	static int mod = (int) (1e9 + 7);
	int mod2 = 998244353;
	int parent[];
	int rank[];

	public static void main(String[] args) throws Exception {
		new Practice().run();
	}

	void run() throws Exception {
		in = new FastReader();
		out = new PrintWriter(System.out);
		int T = (multipleTC) ? ni() : 1;
		pre();
		for (int t = 1; t <= T; t++)
			solve(t);
		out.flush();
		out.close();
	}

	void pre() throws Exception {
	}

	void solve(int TC) throws Exception {
		int q = ni();
		HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
		int index = 0;
		for (int query = 0; query < q; query++) {
			int type = ni();
			if (type == 1) {
				int x = ni();
				if (!map.containsKey(x)) {
					map.put(x, new ArrayList<>());
				}
				map.get(x).add(index++);
			} else {
				int x = ni(), y = ni();
				if (x == y || !map.containsKey(x)) {
					continue;
				}
				ArrayList<Integer> indices_x = map.get(x);
				ArrayList<Integer> indices_y = map.getOrDefault(y, new ArrayList<Integer>());
				if (indices_x.size() > indices_y.size()) {
					for (int i : indices_y) {
						indices_x.add(i);
					}
					map.remove(x);
					map.put(y, indices_x);
				} else {
					for (int i : indices_x) {
						indices_y.add(i);
					}
					map.put(y, indices_y);
					map.remove(x);
				}
			}
		}

		int res[] = new int[index];
		for (Map.Entry<Integer, ArrayList<Integer>> e : map.entrySet()) {
			ArrayList<Integer> indices = e.getValue();
			for (int i : indices) {
				res[i] = e.getKey();
			}
		}
		pn(printArr(res));

	}

	void union(int u, int v) {
		u = findParent(u);
		v = findParent(v);
		if (rank[u] > rank[v]) {
			parent[v] = u;
		} else if (rank[u] < rank[v]) {
			parent[u] = v;
		} else {
			parent[v] = u;
			rank[u]++;
		}
	}

	int findParent(int v) {
		if (v == parent[v])
			return v;
		return parent[v] = findParent(parent[v]);
	}

	StringBuilder printArr(int arr[]) {
		StringBuilder sb = new StringBuilder();
		int n = arr.length;
		for (int i = 0; i < n; i++) {
			sb.append(arr[i] + " ");
		}
		return sb;
	}

	StringBuilder printArr(long arr[]) {
		StringBuilder sb = new StringBuilder();
		int n = arr.length;
		for (int i = 0; i < n; i++) {
			sb.append(arr[i] + " ");
		}
		return sb;
	}

	class pair {
		int x, y;

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

		@Override
		public String toString() {
			return " " + x + ", " + y + "]";
		}

	}

	class pairL {
		long x, y;

		pairL(long x, long y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public String toString() {
			return " " + x + ", " + y + "]";
		}

	}

	boolean isSorted(int arr[]) {
		for (int i = 0; i < arr.length - 1; i++) {
			if (arr[i] > arr[i + 1]) {
				return false;
			}
		}
		return true;
	}

	void swap(int arr[], int x, int y) {
		int t = arr[x];
		arr[x] = arr[y];
		arr[y] = t;
	}

	static int bitCount(int x) {
		return x == 0 ? 0 : (1 + bitCount(x & (x - 1)));
	}

	void sort(long arr[]) {
		ArrayList<Long> list = new ArrayList<>();
		for (int i = 0; i < arr.length; i++)
			list.add(arr[i]);
		Collections.sort(list);
		for (int i = 0; i < arr.length; i++)
			arr[i] = list.get(i);
	}

	static void dbg(Object... o) {
		System.err.println(Arrays.deepToString(o));
	}

	ArrayList<Integer> primeFactorization(int n) {
		ArrayList<Integer> factorization = new ArrayList<>();
		while (n % 2 == 0) {
			factorization.add(2);
			n /= 2;
		}
		for (int d = 3; d * d <= n; d += 2) {
			while (n % d == 0) {
				factorization.add(d);
				n /= d;
			}
		}
		if (n > 1)
			factorization.add(n);
		return factorization;
	}

	private ArrayList<Integer> getPrimes(int n) {
		boolean sieve[] = new boolean[n + 1];
		sieve[0] = sieve[1] = true;
		for (int i = 2; i * i <= n; i++) {
			if (!sieve[i]) {
				for (int j = i * i; j <= n; j += i) {
					sieve[j] = true;
				}
			}
		}
		ArrayList<Integer> primes = new ArrayList<>();
		for (int i = 2; i <= n; i++) {
			if (!sieve[i]) {
				primes.add(i);
			}
		}
		return primes;
	}

	public static boolean isPrime(long n) {
		if (n < 2)
			return false;
		if (n == 2 || n == 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;
		long sqrtN = (long) Math.sqrt(n) + 1;
		for (long i = 6L; i <= sqrtN; i += 6) {
			if (n % (i - 1) == 0 || n % (i + 1) == 0)
				return false;
		}
		return true;
	}

	public static long gcd(long a, long b) {
		if (a > b)
			a = (a + b) - (b = a);
		if (a == 0L)
			return b;
		return gcd(b % a, a);
	}

	public long binaryExpo(long base, long exp) {
		long res = 1;
		while (exp > 0) {
			if ((exp & 1) == 1)
				res = res * base;
			base = base * base;
			exp >>= 1;
		}
		return res;
	}

	public long pow(long base, long exp, long MOD) {
		base %= MOD;
		long res = 1;
		while (exp > 0) {
			if ((exp & 1) == 1)
				res = res * base % MOD;
			base = base * base % MOD;
			exp >>= 1;
		}
		return res;
	}

	public static long totient(long n) {
		long result = n;
		for (int p = 2; p * p <= n; ++p)
			if (n % p == 0) {
				while (n % p == 0)
					n /= p;
				result -= result / p;
			}
		if (n > 1)
			result -= result / n;
		return result;
	}

	int bit(long n) {
		return (n == 0) ? 0 : (1 + bit(n & (n - 1)));
	}

	public long max(long... arr) {
		long max = arr[0];
		for (long itr : arr)
			max = Math.max(max, itr);
		return max;
	}

	public int max(int... arr) {
		int max = arr[0];
		for (int itr : arr)
			max = Math.max(max, itr);
		return max;
	}

	public long min(long... arr) {
		long min = arr[0];
		for (long itr : arr)
			min = Math.min(min, itr);
		return min;
	}

	public int min(int... arr) {
		int min = arr[0];
		for (int itr : arr)
			min = Math.min(min, itr);
		return min;
	}

	public long sum(long... arr) {
		long sum = 0;
		for (long itr : arr)
			sum += itr;
		return sum;
	}

	public long sum(int... arr) {
		long sum = 0;
		for (int itr : arr)
			sum += itr;
		return sum;
	}

	void p(Object o) {
		out.print(o);
	}

	void pn(Object o) {
		out.println(o);
	}

	void pni(Object o) {
		out.println(o);
		out.flush();
	}

	String n() throws Exception {
		return in.next();
	}

	String nln() throws Exception {
		return in.nextLine();
	}

	int ni() throws Exception {
		return Integer.parseInt(in.next());
	}

	long nl() throws Exception {
		return Long.parseLong(in.next());
	}

	long[] readArr(int n) throws Exception {
		long arr[] = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = nl();
		}
		return arr;
	}

	double nd() throws Exception {
		return Double.parseDouble(in.next());
	}

	class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

		public FastReader(String s) throws Exception {
			br = new BufferedReader(new FileReader(s));
		}

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

		String nextLine() throws Exception {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				throw new Exception(e.toString());
			}
			return str;
		}
	}
}