import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int w, n, a, b, i, swap;
		String str;
		w = scan.nextInt();
		int[] amidakuji = new int[w];
		n = scan.nextInt();
		for (i = 0; i < w; i ++) amidakuji[i] = i;
		for (i = 0; i < n; i ++) {
			str = scan.next();
//			a = scan.nextInt();
//			b = scan.nextInt();
			String[] seisuu = str.split(",", 0);
			a = Integer.parseInt(seisuu[0]);
			b = Integer.parseInt(seisuu[1]);
			a --; b --;
			swap = amidakuji[a]; amidakuji[a] = amidakuji[b]; amidakuji[b] = swap;
		}
		for (i = 0; i < w; i ++) {
			System.out.println(amidakuji[i] + 1);
		}
	}
}
/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