#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define rep(i, n) for(int i=0;i=0;--i) const int inf=1e9+7; const ll mod=1e9+7; const ll big=1e18; const double PI=3.14159265359; int par[500005], siz[500005], num[500005]; int root(int x){ while(x!=par[x]) x = par[x]; return x; } int main() { int N, Q; scanf("%d %d", &N, &Q); int T[Q], A[Q], B[Q]; for(int i=0;i siz[rootb]) swap(roota, rootb); par[roota] = rootb; siz[rootb] += siz[roota]; } } if(T[i]==2){ roota = root(A[i]); for(int j=0;j