import time dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes] N,M = [int(i) for i in input().split()] battle = [] for i in range (M): battle.append(list(int(i) for i in input().split())) monkey = list(range(1,N+1)) monk = monkey.copy() group = [] for i in range(N): group.append([(monkey[i])]) #print(group,battle) def bat(a,b): if a == b: return a elif len(a) == len(b): if a[0] < b[0]: for i in b: monk[i-1] = a[0] return a + b if b[0] < a[0]: for i in a: monk[i-1] = b[0] return b + a elif len(a) > len(b): for i in b: monk[i-1] = a[0] return a + b elif len(b) > len(a): for i in a: monk[i-1] = b[0] return b + a for i in range(M): count = 0 k = m = 0 for j in range(len(group)): if battle[i][0] in group[j]: x = group[j] k = j count +=1 if battle[i][1] in group[j]: y = group[j] m = j count+=1 if count == 2: break if k != m: group.pop(k) if k > m: group.pop(m) if k < m: group.pop(m-1) if x == y: group.pop(k) group.append(bat(x,y)) for i in range(N): print(monk[i])