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: // idk
  import java.util.*;
  import java.io.*;
  public class Solution {
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
          public FastReader() {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
          String next() {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
          int nextInt() {
              return Integer.parseInt(next());
          }
          long nextLong() {
              return Long.parseLong(next());
          }
          double nextDouble() {
              return Double.parseDouble(next());
          }
          String nextLine() {
              String str = "";
              try {
                  str = br.readLine();
              } catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
      }
      static void sort(int a[]){ // int -> long
          ArrayList<Integer> arr=new ArrayList<>(); // Integer -> Long
          for(int i=0;i<a.length;i++)
          arr.add(a[i]);
          Collections.sort(arr);
          for(int i=0;i<a.length;i++)
          a[i]=arr.get(i);
          
      }
      private static long gcd(long a, long b){
          if(b==0)return a;
          return gcd(b,a%b);
      }
      private static long pow(long x,long y){
          if(y==0)return 1;
          long temp = pow(x, y/2);
          if(y%2==1){
              return x*temp*temp;
          }
          else{
              return temp*temp;
          }
      }
      static int log(long n){
          int res = 0;
          while(n>0){
              res++;
              n/=2;
          }
          return res;
      }
  
      static int mod = (int)1e9+7;
      static PrintWriter out;
      static FastReader sc ;
      public static void main(String[] args) throws IOException {
          sc = new FastReader();
          out = new PrintWriter(System.out);
          // primes();
          int n = sc.nextInt();
          int[][]arr = new int[n][3];
          for(int i=0;i<n;i++){
              int a = sc.nextInt();
              arr[i][0] = a;
              if(a==1){
                  for(int j=1;j<2;j++)arr[i][j] = sc.nextInt();
              }
              else
                  for(int j=1;j<3;j++)arr[i][j] = sc.nextInt();
          }
          // for(int i=0;i<n;i++){
          //     for(int j=0;j<3;j++)
          //         System.out.print(arr[i][j]+" ");
          //     System.out.println("__"    );
          // }
          solver(arr, n);
          // ================================ //
          out.flush();
      }
  
      public static void solver(int[][]arr, int n) {
          int[]par = new int[(int)(5*(1e5)+1)];
          for(int i=0;i<par.length;i++)par[i] = i;
          Stack<Integer> st = new Stack<>();
          for(int i=n-1;i>=0;i--){
              if(arr[i][0]==1){
                  st.push(find(par, arr[i][1]));
              }
              else{
                  union(par, arr[i][1], arr[i][2]);
              }
          }
  
          for(;st.size()>0;)out.print(st.pop()+" ");
      }
  
      static int find(int par[], int i)
      {
          // if (par[i] == i)
          //     return i;
          // int res = find(par, par[i]);
          // par[i] = res;
          return par[i];
      }
      static void union(int par[], int x, int y)
      {
          // System.out.println(x+"__"+    y);
          // int yset = find(par, y);
          // System.out.println(xset+"__"+    yset);
          par[x] = par[y];
      }
  }
  
  