import sys sys.setrecursionlimit(10**8) n,q=map(int,input().split()) S={i for i in range(1,n+1)} par=[i for i in range(n+1)] rank=[0]*(n+1) def find(x): if par[x]==x: return x else: par[x]=find(par[x]) return par[x] def same(x,y): return find(x)==find(y) def unit(x,y): global S x=find(x) y=find(y) if x==y: return 0 if rank[x]