import java.sql.Array;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int N, M;
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();

        int[] hunters = new int[N];
        int[] positionsOfHunter = new int[N];
        ArrayList<Integer>[] positionsOfGrooves = new ArrayList[100_000_000];
        for (int i = 0; i < N; ++i) {
            hunters[i] = i + 1;
            positionsOfHunter[i] = i + 1;
        }
        for (int i = 0; i < M; ++i) {
           int x1, y1, x2, y2;
           x1 = sc.nextInt() - 1;
           y1 = sc.nextInt() - 1;
           x2 = sc.nextInt() - 1;
           y2 = sc.nextInt() - 1;

           if (positionsOfGrooves[y1] == null) {
               positionsOfGrooves[y1] = new ArrayList<>();
           }
               positionsOfGrooves[y1].add(x1);
               positionsOfGrooves[y1].add(x2);
        }

        for (int i = 0; i < positionsOfGrooves.length; i++) {
            if (positionsOfGrooves[i] == null) {
                continue;
            }
            for (int j = 0; j < positionsOfGrooves[i].size(); j+=2) {
                int h1, h2;
                int x1, x2;
                x1 = positionsOfGrooves[i].get(j);
                x2 = positionsOfGrooves[i].get(j+1);
                h1 = hunters[x1];
                h2 = hunters[x2];
                hunters[x1] = h2;
                hunters[x2] = h1;
            }
        }

        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; j++) {
                if (hunters[j] == i + 1) {
                    System.out.println(j + 1);
                    break;
                }
            }
        }
    }
}
