#include #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define endl "\n" const int N=2e5+10; int fa[N]; int find(int x){ if(fa[x]!=x) return find(fa[x]); return x; } void solved(){ int n,q; cin>>n>>q; set s; for(int i=1;i<=n;i++){ fa[i]=i; s.insert(i); } while(q--){ int op; cin>>op; if(op==1){ int u,v; cin>>u>>v; if(find(u)==find(v)) continue; int fu=find(u),fv=find(v); s.erase(fv); fa[fv]=fu; } else{ int v; cin>>v; int fv=find(v); if(s.size()==1){ cout<<-1<