#include <stdio.h>

int main(){

	int w = 0, y = 0, i, t[30] = {},a=0,b=0;

	scanf("%d%d", &w, &y);

	for (i = 0; i < w; i++){
		t[i] = i+1;
	}
	for (i = 0; i < y; i++){
		scanf("%d,%d", &a, &b);
		int k = 0;
		k = t[a - 1];
		t[a - 1] = t[b - 1];
		t[b - 1] = k;
	}
	for (i = 0; i <= y; i++){
		printf("%d\n",t[i]);
	}

	return 0;
}