
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] argv) throws IOException {
        //*
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        int[] lines = new int[Integer.parseInt(in.readLine())];
        for (int i = 0; i < lines.length; i++) {
            lines[i] = i + 1;
        }

        int count = 1;
        count = Integer.parseInt(in.readLine());

        while (count-- > 0) {
            String[] s = in.readLine().split(",");
            swap(lines, Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
        }
        for (int i : lines) {
            System.out.println(i);
        }
        //*/
    }

    private static void swap(int[] lines, int a, int b) {
        int temp = lines[a];
        lines[a] = lines[b];
        lines[b] = temp;
    }
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz