#include #include using namespace std; using namespace atcoder; using ll = long long; using Graph = vector >; using mint = modint998244353; const int INF = 1e9; const int MOD = 1e9+7; const ll LINF = 1e+18; #define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i)) #define REP2(i, s, n) for (int i = (s); i < (int)(n); i++) #define YesNo(T) if(T){cout<<"Yes"< #define VL vector #define VC vector #define VVI vector > #define VVL vector > #define VVC vector > #define VPII vector > #define VPLL vector > template inline void printVec(std::vector v){ REP(i,v.size()){ if(i) std::cout << " "; std::cout << v[i]; } std::cout << std::endl; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); int N,Q; cin >> N >> Q; dsu d(N); REP(i,Q){ int q; cin >> q; if(q == 1){ int u,v; cin >> u >> v; u--;v--; d.merge(u,v); } else{ int v; cin >> v; v--; if(d.size(v) == N){ cout << -1 << endl; continue; } REP(i,N){ if(!d.same(v,i)){ cout << i + 1 << endl; break; } } } } }