import copy
import sys
lines = sys.stdin.readlines()
N,M = (int(lines[0].split()[0]), int(lines[0].split()[1]))

#mat = [[-1 for _ in range(N)] for _ in range(N)]
positions = [i for i in range(N)]

to_sort = []
for i in range(M):
    x,y,endx,_ = [int(x)-1 for x in lines[i+1].split()]
    new_pos = copy.deepcopy(positions)
    new_pos[x] = positions[endx]
    new_pos[endx] = positions[x]
    positions = new_pos


#positions = [x+1 for x in positions]

output = [-1 for _ in range(N)]
for i in range(N):
    output[positions[i]] = i+1

for i in output:
    print(i)

