num_hunt, num_groov = map(int, input().split(" "))

grooves = {}
y_max = -1
for i in range(num_groov):
    x1, y1, x2, y2 = map(int, input().split(" "))
    grooves[(x1, y1)] = (x2, y2)
    grooves[(x2, y2)] = (x1, y1)
    y_max = max(y_max, y1)

for hx in range(0, num_hunt):
    hx += 1
    hy = 0

    while hy <= y_max:
        hy += 1
        if (hx, hy) in grooves:
            hx = grooves[(hx, hy)][0]
    print(hx)
