
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w=sc.nextInt();
		int n=sc.nextInt();
		int[][] list=new int[n][2];
		int[] answer=new int[w];

		for(int i=0; i<n; i++){
			String str=sc.next();
			String[] ab=str.split(",");
			list[i][0]=Integer.parseInt(ab[0]);
			list[i][1]=Integer.parseInt(ab[1]);
		}




		sc.close();

		//MyBLAS.Calc.pMat(list);

		for(int i=1; i<=w; i++){
			int c=move(list,i);
			answer[c-1]=i;
		}

		for(int k=0; k<w; k++){
			System.out.println(answer[k]);
		}



	}

	public static int move(int[][] a,int b){

		for(int i=0; i<a.length; i++){
			if(b==a[i][0]){
				b=a[i][1];
			}else if(b==a[i][1]){
				b=a[i][0];
			}
		}
		return b;
	}
}
/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