#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int w, n,array[30],right,left;
	scanf("%d%d", &w, &n);
	for (int i = 1; i < w+1; i++) {
		array[i] = i;
	}
	for (int j = 0; j < n; j++) {
		scanf("%d,%d", &right, &left);
		swap(array[right], array[left]);
	}

	for (int i = 1; i <= w; i++) {
		printf("%d\n", array[i]);
	}

	return 0;
}
