#include<bits/stdc++.h>
using namespace std;
int l[100001];
int wielkosc[10001];
int ile[100001];
int f(int a){
if(l[a]==a)return a;
l[a]=f(l[a]);
return l[a];
}
void u(int a, int b){
a=f(a);
b=f(b);
if(a!=b){
ile[wielkosc[a]]--;
ile[wielkosc[b]]--;
wielkosc[a]+=wielkosc[b];
l[b]=a;
++ile[wielkosc[a]];
}
}
int main(){
int n, a, b;
bool c;
for(int i=1; i<=100000; ++i){
wielkosc[i]=1;
l[i]=i;
ile[i]=0;
}
ile[1]=100000;
cin >> n;
for (int i=0; i<n; ++i){
cin >> c;
if(c==0){
cin >> a >> b;
u(a, b);
}else{
cin >> a;
cout << ile[a] << endl;
}
}
//8 0 1 2 0 2 3 0 1 4 0 4 5 1 1 1 2 1 3 1 4
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBsWzEwMDAwMV07CmludCB3aWVsa29zY1sxMDAwMV07CmludCBpbGVbMTAwMDAxXTsKCgppbnQgZihpbnQgYSl7CiAgICBpZihsW2FdPT1hKXJldHVybiBhOwogICAgbFthXT1mKGxbYV0pOwogICAgcmV0dXJuIGxbYV07Cn0Kdm9pZCB1KGludCBhLCBpbnQgYil7CiAgICBhPWYoYSk7CiAgICBiPWYoYik7CiAgICBpZihhIT1iKXsKICAgIGlsZVt3aWVsa29zY1thXV0tLTsKICAgIGlsZVt3aWVsa29zY1tiXV0tLTsKICAgIHdpZWxrb3NjW2FdKz13aWVsa29zY1tiXTsKICAgIGxbYl09YTsKICAgICsraWxlW3dpZWxrb3NjW2FdXTsKICAgIH0KfQoKaW50IG1haW4oKXsKCiAgICBpbnQgbiwgYSwgYjsKICAgIGJvb2wgYzsKICAgIGZvcihpbnQgaT0xOyBpPD0xMDAwMDA7ICsraSl7CiAgICAgICAgd2llbGtvc2NbaV09MTsKICAgICAgICBsW2ldPWk7CiAgICAgICAgaWxlW2ldPTA7CiAgICB9CiAgICBpbGVbMV09MTAwMDAwOwogICAgY2luID4+IG47CgogICAgZm9yIChpbnQgaT0wOyBpPG47ICsraSl7CiAgICAgICAgY2luID4+IGM7CiAgICAgICAgaWYoYz09MCl7CiAgICAgICAgICAgIGNpbiA+PiBhID4+IGI7CiAgICAgICAgICAgIHUoYSwgYik7CiAgICAgICAgfWVsc2V7CiAgICAgICAgICAgIGNpbiA+PiBhOwogICAgICAgICAgICBjb3V0IDw8IGlsZVthXSA8PCBlbmRsOwogICAgICAgIH0KICAgIH0KLy84IDAgMSAyIDAgMiAzIDAgMSA0IDAgNCA1IDEgMSAxIDIgMSAzIDEgNAogICAgcmV0dXJuIDA7Cgp9Cg==