import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int w = sc.nextInt();
		int[] ints = new int[w];
		for (int i=0; i<w; i++) {
			ints[i] = i+1;
		}
		int n = sc.nextInt();
		String[] strs = new String[2];
		for (int i=0; i<n; i++) {
			strs = sc.next().split(",");
			int L = Integer.parseInt(strs[0]) - 1;
			int R = Integer.parseInt(strs[1]) - 1;
			int temp = ints[L];
			ints[L] = ints[R];
			ints[R] = temp;
		}
		for (int i=0; i<w; i++) {
			System.out.println(ints[i]);
		}
	}
}

/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