#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;
const int N=5e5+10;
int q,x,op,y,fa[N];
struct node{
int a,b,c;
}p[N];
int find(int x){
if(fa[x]==x) return x;
else return fa[x]=find(fa[x]);
}
vector<int> v;
int main(){
scanf("%d",&q);
for(int i=1;i<N;i++) fa[i]=i;
for(int i=1;i<=q;i++){
scanf("%d",&op);y=0;
if(op==1)scanf("%d",&x);
else scanf("%d%d",&x,&y);
p[i]={op,x,y};
}
for(int i=q;i>=1;i--){
if(p[i].a==1){
int now=fa[p[i].b];
v.push_back(now);
}else{
fa[p[i].b]=fa[p[i].c];
}
}
for(int i=v.size()-1;i>=0;i--){
cout<<v[i]<<" ";
}cout<<endl;
}
|