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 javax.print.attribute.standard.MediaSize;
  import java.io.BufferedReader;
  import java.io.BufferedWriter;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.lang.reflect.Array;
  import java.util.*;
  import java.util.stream.Stream;
  
  public class Program {
  
      static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
  
      public static void main(String[] args) throws NumberFormatException, IOException {
  
          //int cases = Integer.parseInt(reader.readLine());
          int cases = 1;
          int mod = 998244353;
  
          while(cases-- > 0) {
  
              String[] firstLine = reader.readLine().split(" ");
              int q = Integer.parseInt(firstLine[0]);
              /*int k = Integer.parseInt(firstLine[1]);
              int x = Integer.parseInt(firstLine[2]);*/
  
             int[][] queries = new int[q][];
             int i=0;
             while(q-->0) {
                 queries[i++] = convertToIntPrimitiveArray();
             }
  
             i= queries.length-1;
            int[] map = new int[500001];
            for(int j=0;j<map.length;j++) {
                map[j] = j;
            }
  
             List<Integer> ans = new ArrayList<>();
  
             while(i>=0) {
                 if(queries[i][0] == 2) {
                     map[queries[i][1]] = map[queries[i][2]];
                 }else {
                     ans.add(map[queries[i][1]]);
                 }
                 i--;
             }
  
              for(int j=ans.size()-1;j>=0;j--) {
                  out.append(ans.get(j) + " ");
              }
  
          }
  
          out.flush();
  
      }
  
       public static int ub(long[] arr, long num) {
          int start = 0;
          int end = arr.length;
          int mid = 0;
  
          while(start<end) {
              mid = start + (end-start)/2;
              if(arr[mid] < num) {
                  start = mid+1;
              }else {
                  end = mid;
              }
          }
          return start;
       }
  
      public static int[] convertToIntPrimitiveArray() throws IOException {
          String[] str = reader.readLine().split(" ");
          return Stream.of(str).mapToInt(Integer::parseInt).toArray();
      }
  
      public static Integer[] convertToIntArray(String[] str) {
          Integer[] arr = new Integer[str.length];
          for(int i=0;i<str.length;i++) {
              arr[i] = Integer.parseInt(str[i]);
          }
          return arr;
      }
  
      public static Long[] convertToLongArray(String[] str) {
          Long[] arr = new Long[str.length];
          for(int i=0;i<str.length;i++) {
              arr[i] = Long.parseLong(str[i]);
          }
          return arr;
      }
  
      public static long[] convertToLongPrimitiveArray() throws IOException {
          String[] str = reader.readLine().split(" ");
          return Stream.of(str).mapToLong(Long::parseLong).toArray();
      }
  
      public static void printYes() throws IOException {
          out.append("YES" + "\n");
      }
  
      public static void printNo() throws IOException {
          out.append("NO" + "\n");
      }
  
      public static void printNumber(long num) throws IOException {
          out.append(num + "\n");
      }
  
      public static long hcf(long a, long b) {
          if(b==0) return a;
          return hcf(b, a%b);
      }
  
      public static int findSet(int[] parent, int[] rank, int v) {
          if(v==parent[v]) {
              return v;
          }
          parent[v] = findSet(parent, rank, parent[v]);
          return parent[v];
      }
  
      public static void unionSet(int[] parent, int[] rank, int a, int b) {
  
          a = findSet(parent, rank, a);
          b = findSet(parent, rank, b);
  
          if(a == b) {
              return;
          }
  
          if(rank[a] < rank[b]) {
              int temp = a;
              a = b;
              b = temp;
          }
  
          parent[b] = a;
          if(rank[a] == rank[b]) {
              rank[a]++;
          }
  
      }
  
      public static void makeSet(int[] parent, int[] rank, int v) {
          parent[v] = v;
          rank[v] = 0;
      }
  
      public static long modularDivision(long a, long b, int mod) {
          if(a==0) return 1;
          a %= mod;
          long res = 1L;
          while(b > 0) {
              if((b&1)==1) {
                  res = (res * a)%mod;
              }
              a = (a*a)%mod;
              b >>= 1;
          }
          return res;
      }
  
      public static void customSort(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);
          return;
      }
  
      public static void customSortLong(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);
          return;
      }
  
      public static long[] factorial(int n, int mod) {
          long[] fact = new long[n+1];
          fact[0] = 1;
          for(int i=1;i<fact.length;i++) {
              fact[i] = (i*fact[i-1] + mod)%mod;
          }
          return fact;
      }
  
      public static List<Integer> primeNumbers(int num) {
          boolean[] arr = new boolean[num+1];
          List<Integer> primes = new ArrayList<>();
  
          for(int i=2;i*i<=num;i++) {
              if(!arr[i]) {
                  for(int j=i;j*i<=num;j++) {
                      arr[j*i] = true;
                  }
              }
          }
  
          for(int i=2;i<=num;i++) {
              if(!arr[i]) {
                  primes.add(i);
              }
          }
          return primes;
      }
  
  
  }