n, m = list(map(int, input("").split(" ")))

grooves = []

for i in range(m):
    a, b, c, d = list(map(int, input("").split(" ")))
    grooves.append((b,a,c))

hunters = list(range(1, n + 1))

grooves = list(sorted(grooves, key = lambda a: a[0]))

for y, x1, x2 in grooves:
    hunters[x1 - 1], hunters[x2 - 1] = hunters[x2 - 1], hunters[x1 - 1]

hunters = list(sorted(zip(hunters, range(1, n+1)), key = lambda a: a[0]))

for hunter, pos in hunters:
    print(pos)

