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.util.*;
  import java.io.*;
  //import javafx.util.*;
  
  public class Solution
  {
         static class Reader {
          final private int BUFFER_SIZE = 1 << 16;
          private DataInputStream din;
          private byte[] buffer;
          private int bufferPointer, bytesRead;
   
          public Reader()
          {
              din = new DataInputStream(System.in);
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public Reader(String file_name) throws IOException
          {
              din = new DataInputStream(
                  new FileInputStream(file_name));
              buffer = new byte[BUFFER_SIZE];
              bufferPointer = bytesRead = 0;
          }
   
          public String readLine() throws IOException
          {
              byte[] buf = new byte[64]; // line length
              int cnt = 0, c;
              while ((c = read()) != -1) {
                  if (c == '\n') {
                      if (cnt != 0) {
                          break;
                      }
                      else {
                          continue;
                      }
                  }
                  buf[cnt++] = (byte)c;
              }
              return new String(buf, 0, cnt);
          }
   
          public int nextInt() throws IOException
          {
              int ret = 0;
              byte c = read();
              while (c <= ' ') {
                  c = read();
              }
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (neg)
                  return -ret;
              return ret;
          }
   
          public long nextLong() throws IOException
          {
              long ret = 0;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
              if (neg)
                  return -ret;
              return ret;
          }
   
          public double nextDouble() throws IOException
          {
              double ret = 0, div = 1;
              byte c = read();
              while (c <= ' ')
                  c = read();
              boolean neg = (c == '-');
              if (neg)
                  c = read();
   
              do {
                  ret = ret * 10 + c - '0';
              } while ((c = read()) >= '0' && c <= '9');
   
              if (c == '.') {
                  while ((c = read()) >= '0' && c <= '9') {
                      ret += (c - '0') / (div *= 10);
                  }
              }
   
              if (neg)
                  return -ret;
              return ret;
          }
   
          private void fillBuffer() throws IOException
          {
              bytesRead = din.read(buffer, bufferPointer = 0,
                                   BUFFER_SIZE);
              if (bytesRead == -1)
                  buffer[0] = -1;
          }
   
          private byte read() throws IOException
          {
              if (bufferPointer == bytesRead)
                  fillBuffer();
              return buffer[bufferPointer++];
          }
   
          public void close() throws IOException
          {
              if (din == null)
                  return;
              din.close();
          }
      }
      static int parent(int x , int p[])
      {
             if(p[x] == x)
             return x;
             
             return (p[x] = parent(p[x],p));
      }
      
      static void union(int a , int b , int p[] , int size[])
      {
             a = parent(a,p);
             b = parent(b,p);
             
             if(size[a] < size[b])
             {
                    int temp = a;
                    a = b;
                    b = temp;
             }
             p[b] = a;
             size[a] += size[b];
      }
     // int ass;
      
     // static long mod = 998244353;
      static long pow(long a , long b)
      {
             if(b == 0)
             return 1;
             
             long ans = pow(a,b/2);
             if(b%2 == 0)
             return ans*ans%mod;
             
             return ans*ans%mod*a%mod;
      }
      
      static double pow(double a , int b)
      {
             if(b == 0)
             return 1.0;
             
             double x = pow(a,b/2);
             if(b%2 == 0)
             return x*x;
             
             return x*x*a;
      }
      static long ways(long n)
      {
             long ans = 0;
             for(long i = 2 ; i <= 1000000 ; i++)
             {
                    long sum = i*i*i;
                    ans += n/sum;
                    
                    if(ans < 0)
                    return ans;
             }
             return ans;
             
      }
      static long calc(long n)
      {
             int x = 0;
             if(n%3 != 0)
             x++;
             
             return n/3+x;
      }
      
      //static pair st[];
      static int sz = 1;
      static long mod = 1000000007;
      
    public static void main(String []args)
    {
           Scanner sc = new Scanner(System.in);
           int n = sc.nextInt();
           int arr[][] = new int[n][3];
           int tot = 0;
           for(int i = 0 ; i < n ; i++)
           {
                  arr[i][0] = sc.nextInt();
                  if(arr[i][0] == 1)
                  {
                         arr[i][1] = sc.nextInt();
                         arr[i][2] = 0;
                         tot++;
                  }
                  
                  else
                  {
                         arr[i][1] = sc.nextInt();
                         arr[i][2] = sc.nextInt();
                  }
                  
           }
           HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
           int ans[] = new int[tot];
           tot--;
           for(int i = n-1 ; i >= 0 ; i--)
           {
                  if(arr[i][0] == 1)
                  {
                         if(map.containsKey(arr[i][1]))
                         {
                               ans[tot] = map.get(arr[i][1]);
                         }
                         
                         else
                         ans[tot] = arr[i][1];
                         
                         tot--;
                  }
                  
                  else
                  {
                         if(map.containsKey(arr[i][2]))
                         map.put(arr[i][1],map.get(arr[i][2]));
                         
                         else
                         map.put(arr[i][1],arr[i][2]);
                  }
           }
           
           StringBuffer str = new StringBuffer("");
           for(int i = 0 ; i < ans.length; i++)
           {
                  str.append(ans[i] + " ");
           }
           System.out.println(str);
    }
  }
  