import java.io.*;

 public class Main{
	 public static void main(String args[]) throws IOException{
		 BufferedReader bf = new BufferedReader(
				 new InputStreamReader(System.in));
		 int w,n,right,left,x;
		 String str;
		 w = Integer.parseInt(bf.readLine());
		 n = Integer.parseInt(bf.readLine());
		 int[] order = new int[w];
		 for(int i = 0; i < w; i++){
			 order[i] = i+1;
		 }
		 for(int i = 0; i < 2*n; i += 2){
			 str = bf.readLine();
			 String deta[] = str.split(",",0);
			 left = Integer.parseInt(deta[0]);
			 right = Integer.parseInt(deta[1]);
			 x = order[left-1];
			 order[left-1] =order[right-1];
			 order[right-1] = x;
		 }
		 for(int i = 0; i < w; i++){
			 System.out.println(order[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