import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int w, h;
	static int[]amida;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	static boolean read(){
		if(!sc.hasNext())return false;
		w = sc.nextInt(); h = sc.nextInt();
		amida = new int[w+1];
		String line;
		String[] devide = new String[2];
		for(int i = 1; i < w+1; i++)
			amida[i] = i;
		for(int i = 0; i < h; i++){
			line = sc.next();
			devide = line.split(",");
			int exIndex1 = Integer.parseInt(devide[0]);
			int exIndex2 = Integer.parseInt(devide[1]);
			int temp = amida[exIndex1];
			amida[exIndex1] = amida[exIndex2];
			amida[exIndex2] = temp;
		}
		return true;
	}
	static void solve(){
		for(int i = 1; i < w+1; i++){
			System.out.println(amida[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