import java.util.*;

public class Main
{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();

	    int[] lots = new int[w];
	    for(int i = 1; i <= w; ++i){
		lots[i-1] = i;
	    }

	    while(0 < n--){
		String[] horizontal_line = sc.next().split(",");
		swapVerticalLines(lots, Integer.parseInt(horizontal_line[0])-1, Integer.parseInt(horizontal_line[1])-1);
	    }

	    for(int i = 0; i < w; ++i){
		System.out.println(String.valueOf(lots[i]));
	    }
	}
    }

    private static void swapVerticalLines(int[] lots, int line1, int line2){
	int tmp = lots[line1];
	lots[line1] = lots[line2];
	lots[line2] = tmp;
    }
}
/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