class Hunter:
    def __init__(self,x,y):
        self.x = x
        self.y = y

class Groove:
    def __init__(self,start_x,start_y, end_x, end_y):
        self.start_x = start_x
        self.start_y = start_y
        self.end_x = end_x
        self.end_y = end_y

def main():
    line = input()
    line = line.split(" ")
    hunter_count = int(line[0])
    grooves_count = int(line[1])
    grooves = []
    max_y = 0

    for i in range(grooves_count):
        line = input()
        line = line.split(" ")
        grooves.append(Groove(int(line[0]), int(line[1]), int(line[2]), int(line[3])))
        if grooves[i].end_y > max_y:
            max_y = grooves[i].end_y


    hunters = []

    for i in range(1 ,hunter_count+1):
        hunters.append(Hunter(i, 0))

    for i in range(1, max_y + 1):
        for groove in grooves:
            if groove.start_y == i:
                for hunter in hunters:
                    hunter.y = i
                    if hunter.x == groove.start_x:
                        hunter.x = groove.end_x

                    elif hunter.x == groove.end_x:
                        hunter.x = groove.start_x


    for hunter in hunters:
        print(hunter.x)










if __name__ == '__main__':
    main()