import java.util.Scanner;
import java.util.Stack;

public class groove2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Stack<Integer>[] stacks = new Stack[N + 1];
        for (int i = 1; i <= N; i++) {
            stacks[i] = new Stack<>();
            stacks[i].push(i);
        }
        sc.nextLine();
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt();
            sc.nextInt();
            int b = sc.nextInt();
            sc.nextInt();
            sc.nextLine();
            for (int j = 1; j <= N; j++) {
                if (stacks[j].peek() == a) {
                    stacks[j].push(b);
                } else if (stacks[j].peek() == b) {
                    stacks[j].push(a);
                }

            }

        }
        for (int i = 1; i <= N; i++) {
            System.out.println(stacks[i].peek());

        }

    }
}
