#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long base, long long power, long long modd) {
  if (power == 0)
    return 1;
  else if (power % 2 == 0) {
    long long ret = bigmod(base, power / 2, modd);
    return ((ret % modd) * (ret % modd)) % modd;
  } else {
    return ((base % modd) * (bigmod(base, power - 1, modd))) % modd;
  }
}
long long fpow(long long base, long long power) {
  long long ret = 1;
  while (power) {
    if (power % 2 == 0) {
      base = base * base;
      power /= 2;
    } else {
      ret *= base;
      power--;
    }
  }
  return ret;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long a, b, c, d, i, j, cnt = 0, lng, o = 0;
  string st;
  vector<long long> v, u, v2, u2;
  map<long long, long long> mp;
  cin >> lng;
  for (i = 0; i <= 500000; i++) mp[i] = i;
  bool bl[lng];
  for (i = 0; i < lng; i++) {
    bl[i] = 0;
    cin >> a;
    if (a == 1) {
      cin >> b;
      v.push_back(b);
      u.push_back(-1);
    } else {
      cin >> b >> c;
      v.push_back(b);
      u.push_back(c);
      bl[i] = 1;
    }
  }
  for (i = lng - 1; i >= 0; i--) {
    if (bl[i] == 0) {
      v2.push_back(mp[v[i]]);
    } else {
      mp[v[i]] = mp[u[i]];
    }
  }
  for (i = v2.size() - 1; i >= 0; i--) cout << v2[i] << endl;
  return 0;
}

### Prompt

Please create a solution in cpp to the following problem:

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].

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long base, long long power, long long modd) {
  if (power == 0)
    return 1;
  else if (power % 2 == 0) {
    long long ret = bigmod(base, power / 2, modd);
    return ((ret % modd) * (ret % modd)) % modd;
  } else {
    return ((base % modd) * (bigmod(base, power - 1, modd))) % modd;
  }
}
long long fpow(long long base, long long power) {
  long long ret = 1;
  while (power) {
    if (power % 2 == 0) {
      base = base * base;
      power /= 2;
    } else {
      ret *= base;
      power--;
    }
  }
  return ret;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long a, b, c, d, i, j, cnt = 0, lng, o = 0;
  string st;
  vector<long long> v, u, v2, u2;
  map<long long, long long> mp;
  cin >> lng;
  for (i = 0; i <= 500000; i++) mp[i] = i;
  bool bl[lng];
  for (i = 0; i < lng; i++) {
    bl[i] = 0;
    cin >> a;
    if (a == 1) {
      cin >> b;
      v.push_back(b);
      u.push_back(-1);
    } else {
      cin >> b >> c;
      v.push_back(b);
      u.push_back(c);
      bl[i] = 1;
    }
  }
  for (i = lng - 1; i >= 0; i--) {
    if (bl[i] == 0) {
      v2.push_back(mp[v[i]]);
    } else {
      mp[v[i]] = mp[u[i]];
    }
  }
  for (i = v2.size() - 1; i >= 0; i--) cout << v2[i] << endl;
  return 0;
}

```