def main():
    hunters, grooves_count = list(map(int, input().split(" ")))

    grooves = []
    for _ in range(grooves_count):
        xp, yp, xq, yq = map(int, input().split(" "))

        if xp > xq:
            xp, xq = xq, xp

        grooves.append((yp, xp, xq))

    grooves.sort(key=lambda t: t[0])

    A = list(range(hunters + 1))
    pos = list(range(hunters + 1))

    for _, a, b in grooves:

        ha, hb = A[a], A[b]
        if ha == hb:
            continue

        A[a], A[b] = hb, ha

        pos[ha], pos[hb] = b, a

    out = []
    for h in range(1, hunters + 1):
        out.append(str(pos[h]))

    print("\n".join(out))

main()