#include <bits/stdc++.h>
using namespace std;
template <class T>
void print(vector<T> a) {
  int n = a.size();
  for (long long i = 0; i < n; ++i) {
    cout << a[i] << (i == n - 1 ? "\n" : " ");
  }
}
int sum_vector(vector<int> v) { return accumulate(v.begin(), v.end(), 0); }
void sort_vector(vector<int> &v) { sort(v.begin(), v.end()); }
void sort_comp(vector<int> &v, bool func(int, int)) {
  sort(v.begin(), v.end(), func);
}
bool comp(int a, int b) { return a < b; }
struct CustomCompare {
  bool operator()(pair<int, int> lhs, pair<int, int> rhs) {
    return lhs.first > rhs.first;
  }
};
long long gcd(long long a, long long b) {
  a = abs(a);
  b = abs(b);
  while (a) {
    long long temp = a;
    a = b % a;
    b = temp;
  }
  return abs(b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
string binary(long long num) {
  string ans = "";
  do {
    ans = to_string(num % 2) + ans;
    num /= 2;
  } while (num);
  return ans;
}
const int mxn = 5e5 + 7;
const int d = 18;
const int mill = 1e6 + 3;
const long long mod = 998244353;
long long pwr(long long num, long long p) {
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = (res * num) % mod;
    num = (num * num) % mod;
    p /= 2;
  }
  return res;
}
long long inverse(long long num) { return pwr(num, mod - 2); }
long long get_rand(long long n) { return ((rand() << 15) + rand()) % n; }
void solve() {
  int q;
  cin >> q;
  vector<int> show(mxn);
  for (int i = 0; i < mxn; i++) {
    show[i] = i;
  }
  vector<array<int, 3>> arr(q);
  for (int i = 0; i < q; i++) {
    cin >> arr[i][0];
    cin >> arr[i][1];
    arr[i][2] = -1;
    if (arr[i][0] == 2) cin >> arr[i][2];
  }
  vector<int> v;
  for (int i = q - 1; i >= 0; i--) {
    if (arr[i][0] == 1) {
      v.push_back(show[arr[i][1]]);
    } else {
      show[arr[i][1]] = show[arr[i][2]];
    }
  }
  reverse(v.begin(), v.end());
  print(v);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int t = 1;
  for (int ii = 1; ii <= t; ii++) {
    solve();
  }
  return 0;
}

### Prompt

Your challenge is to write a CPP solution 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;
template <class T>
void print(vector<T> a) {
  int n = a.size();
  for (long long i = 0; i < n; ++i) {
    cout << a[i] << (i == n - 1 ? "\n" : " ");
  }
}
int sum_vector(vector<int> v) { return accumulate(v.begin(), v.end(), 0); }
void sort_vector(vector<int> &v) { sort(v.begin(), v.end()); }
void sort_comp(vector<int> &v, bool func(int, int)) {
  sort(v.begin(), v.end(), func);
}
bool comp(int a, int b) { return a < b; }
struct CustomCompare {
  bool operator()(pair<int, int> lhs, pair<int, int> rhs) {
    return lhs.first > rhs.first;
  }
};
long long gcd(long long a, long long b) {
  a = abs(a);
  b = abs(b);
  while (a) {
    long long temp = a;
    a = b % a;
    b = temp;
  }
  return abs(b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
string binary(long long num) {
  string ans = "";
  do {
    ans = to_string(num % 2) + ans;
    num /= 2;
  } while (num);
  return ans;
}
const int mxn = 5e5 + 7;
const int d = 18;
const int mill = 1e6 + 3;
const long long mod = 998244353;
long long pwr(long long num, long long p) {
  long long res = 1;
  while (p > 0) {
    if (p & 1) res = (res * num) % mod;
    num = (num * num) % mod;
    p /= 2;
  }
  return res;
}
long long inverse(long long num) { return pwr(num, mod - 2); }
long long get_rand(long long n) { return ((rand() << 15) + rand()) % n; }
void solve() {
  int q;
  cin >> q;
  vector<int> show(mxn);
  for (int i = 0; i < mxn; i++) {
    show[i] = i;
  }
  vector<array<int, 3>> arr(q);
  for (int i = 0; i < q; i++) {
    cin >> arr[i][0];
    cin >> arr[i][1];
    arr[i][2] = -1;
    if (arr[i][0] == 2) cin >> arr[i][2];
  }
  vector<int> v;
  for (int i = q - 1; i >= 0; i--) {
    if (arr[i][0] == 1) {
      v.push_back(show[arr[i][1]]);
    } else {
      show[arr[i][1]] = show[arr[i][2]];
    }
  }
  reverse(v.begin(), v.end());
  print(v);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int t = 1;
  for (int ii = 1; ii <= t; ii++) {
    solve();
  }
  return 0;
}

```