class union_find: def __init__(self,size): self.table = [-1 for i in range(size)] def find(self,n): while self.table[n] >= 0: n = self.table[n] return n def merge(self,x,y): x = self.find(x) y = self.find(y) if self.table[x] < self.table[y]: self.table[x] += self.table[y] self.table[y] = x elif self.table[x] == self.table[y]: if x > y: self.table[y] += self.table[x] self.table[x] = y elif x == y: pass else: self.table[x] += self.table[y] self.table[y] = x else: self.table[y] += self.table[x] self.table[x] = y A, B = map(int, input().split()) aggregation = union_find(A) for i in range(B): C,D = map(int, input().split()) C = C-1 D = D-1 aggregation.merge(C,D) for u in range(A): print(aggregation.find(u)+1)