N,M=map(int,input().split()) ne=[-1]*N def root(N): if ne[N]<0: return N else: ne[N]=root(ne[N]) return ne[N] def merge(x,y): x,y=root(x),root(y) if x==y: return if x>y: x,y=y,x if ne[x]>ne[y]: x,y=y,x ne[x]+=ne[y] ne[y]=x for _ in range(M): a,b=map(lambda x:int(x)-1,input().split()) a,b=max(a,b),min(a,b) merge(b,a) for i in range(N): print(root(i)+1)