#include<iostream>
#include<cmath>
#include<queue>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const double eps = 1e-6;
const int N = 1e6 + 10;
const int mod = 998244353;
vector<int> a;
int t[N], x[N], y[N];
int p[N], q[N];
int main () {
int qq;
cin>>qq;
for (int i = 1; i <= qq; i ++) {
cin >> t[i] >> x[i];
if (t[i] == 2) cin >> y[i];
}
vector<int> ans;
for (int i = 0; i <= N - 10; i ++)
q[i] = i;
for (int i = qq; i >= 1; i --) {
if (t[i] == 1) {
ans.push_back(q[x[i]]);
}
else if (t[i] == 2) {
q[x[i]] = q[y[i]];
}
}
reverse(ans.begin(), ans.end());
for(int i = 0; i < ans.size(); i ++) cout << ans[i] << " ";
puts("");
return 0;
}
倒着处理。可以把影响变成正向的并且不影响结果