class MonkeyStatus: def __init__(self, n): self.par = [i for i in range(n)] self.size = [1 for i in range(n)] def find(self, x): if self.par[x] == x: return x else: return self.find(self.par[x]) def unite(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.size[x] > self.size[y]: self.par[y] = x self.size[x] += self.size[y] elif self.size[x] < self.size[y]: self.par[x] = y self.size[y] += self.size[x] elif x > y: self.par[x] = y self.size[y] += self.size[x] else: self.par[y] = x self.size[x] += self.size[y] N, M = map(int, input().split()) mStatus = MonkeyStatus(N) for _ in range(M): a, b = map(int, input().split()) mStatus.unite(a - 1, b - 1) for i in range(N): print(mStatus.find(i) + 1)