description: 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].
solution: import sys
  from math import factorial, gcd
  #from math import comb, perm 	
  from collections import Counter, deque, defaultdict
  from bisect import bisect_left, bisect_right 
  from heapq import heappop, heappush, heapify, nlargest, nsmallest
  from itertools import groupby, accumulate
  from copy import deepcopy
  MOD = 10**9+7
  INF = float('inf')
  
  # import io,os
  # input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
  # input = sys.stdin.buffer.readline
  input = sys.stdin.readline
  rl = lambda : list(map(int, input().split()))
  rs = lambda : sys.stdin.readline().strip()
  
  
  # D = defaultdict(list)
  n = 0
  arr = []
  change = []
  for _ in range(int(input())):
  	q = rs().split()
  
  	if q[0] == '1':
  		arr.append(q[-1])
  		# D[q[-1]].append(n)
  		n += 1
  	else:
  		x, y = q[1:]
  		if x == y or n == 0:
  			continue
  		change.append((x, y, n - 1))
  
  
  if change:
  	x, y, idx = change[-1]
  	D = {x: y}
  	j = len(change) - 2
  	for i in range(n-1, -1, -1):
  		if i > idx:
  			continue
  
  		while j >= 0 and change[j][-1] == i:
  			a, b, _ = change[j]
  			if b in D:
  				D[a] = D[b]
  			else:
  				D[a] = b
  			j -= 1
  
  		if arr[i] in D:
  			arr[i] = D[arr[i]]
  		
  print(*arr)