import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N, M = map(int, input().split()) root = [-1] * N def find(x): if root[x] < 0: return x root[x] = find(root[x]) return root[x] def same(x, y): return find(x) == find(y) def merge(x, y): x = find(x) y = find(y) if x == y: return if root[x] == root[y]: x, y = min(x, y), max(x, y) root[x] += root[y] root[y] = x return if -root[x] < -root[y]: x, y = y, x root[x] += root[y] root[y] = x return for _ in range(M): a, b = map(int, input().split()) merge(a - 1, b - 1) for i in range(N): print(find(i) + 1)