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 java.io.*;
  import java.lang.reflect.Array;
  import java.util.*;
  
  public class A {
      //--------------------------INPUT READER---------------------------------//
      static class fs {
          public BufferedReader br;
          StringTokenizer st = new StringTokenizer("");
  
          public fs() { this(System.in); }
          public fs(InputStream is) {
              br = new BufferedReader(new InputStreamReader(is));
          }
          String next() {
              while (!st.hasMoreTokens()) {
                  try { st = new StringTokenizer(br.readLine()); }
                  catch (IOException e) { e.printStackTrace(); }
              }
              return st.nextToken();
          }
  
          int ni() { return Integer.parseInt(next()); }
          long nl() { return Long.parseLong(next()); }
          double nd() { return Double.parseDouble(next()); }
          String ns() { return next(); }
  
          int[] na(long nn) {
              int n = (int) nn;
              int[] a = new int[n];
              for (int i = 0; i < n; i++) a[i] = ni();
              return a;
          }
  
          long[] nal(long nn) {
              int n = (int) nn;
              long[] l = new long[n];
              for(int i = 0; i < n; i++) l[i] = nl();
              return l;
          }
      }
      //-----------------------------------------------------------------------//
  
      //---------------------------PRINTER-------------------------------------//
      static class Printer {
          static PrintWriter w;
          public Printer() {this(System.out);}
          public Printer(OutputStream os) {
              w = new PrintWriter(os);
          }
          public void p(int i) {w.println(i);}
          public void p(long l) {w.println(l);}
          public void p(double d) {w.println(d);}
          public void p(String s) { w.println(s);}
          public void pr(int i) {w.print(i);}
          public void pr(long l) {w.print(l);}
          public void pr(double d) {w.print(d);}
          public void pr(String s) { w.print(s);}
          public void pl() {w.println();}
          public void close() {w.close();}
      }
      //-----------------------------------------------------------------------//
  
      //--------------------------VARIABLES------------------------------------//
      static fs sc = new fs();
      static OutputStream outputStream = System.out;
      static Printer w = new Printer(outputStream);
      static long lma = Long.MAX_VALUE, lmi = Long.MIN_VALUE;
      static long ima = Integer.MAX_VALUE, imi = Integer.MIN_VALUE;
      static long mod = 1000000007;
      //-----------------------------------------------------------------------//
  
      //--------------------------ADMIN_MODE-----------------------------------//
      private static void ADMIN_MODE() throws IOException {
          if (System.getProperty("ONLINE_JUDGE") == null) {
              w = new Printer(new FileOutputStream("output.txt"));
              sc = new fs(new FileInputStream("input.txt"));
          }
      }
      //-----------------------------------------------------------------------//
  
      //----------------------------START--------------------------------------//
      public static void main(String[] args)
              throws IOException {
  
          ADMIN_MODE();
  
  //        int t = sc.ni();while(t-->0)
              solve();
  
  
          w.close();
      }
  
      static void solve() throws IOException {
          int n = sc.ni();
          ArrayDeque<pr2> a = new ArrayDeque<>();
          ArrayDeque<pr> b = new ArrayDeque<>();
  
          for(int i = 0; i < n; i++) {
              int q = sc.ni();
              if(q == 1) a.push(new pr2(i, sc.ni()));
              else b.push(new pr(i, sc.ni(), sc.ni()));
          }
  
          HashMap<Integer, Integer> hm = new HashMap<>();
          ArrayDeque<Integer> q = new ArrayDeque<>();
  
          while(!a.isEmpty()) {
              pr2 curr = a.pop();
              while(!b.isEmpty() && b.peek().id > curr.id) {
                  pr pop = b.pop();
                  int aa = pop.a;
                  int bb = pop.b;
                  if(hm.containsKey(bb)) {
                      bb = hm.get(bb);
                  } else hm.put(aa, bb);
  
                  if(hm.containsKey(aa)) {
                      hm.replace(aa, bb);
                  } else hm.put(aa, bb);
              }
  
              int ans = curr.a;
              if(hm.containsKey(ans)) {
                  ans = hm.get(ans);
              }
  
              q.addFirst(ans);
          }
  
          for(int i: q) {
              w.pr(i+" ");
          }
  
          w.pl();
      }
  
      static class pr2 {
          int id, a;
  
          public pr2(int id, int a) {
              this.id = id;
              this.a = a;
          }
      }
  
      static class pr {
          int id, a, b;
  
          public pr(int id, int a, int b) {
              this.id = id;
              this.a = a;
              this.b = b;
          }
      }
  
  }