#include<iostream>

using namespace std;

int main() {
	int w, n;
	cin >> w;
	cin >> n;
	int *array = new int[w + 1];
	for (int i = 1; i < w + 1; i++) {
		array[i] = i;
	}
	for (int i = 1; i < n+1; i++) {
		int a, b;
		char c;
		cin >> a >> c >> b;
		int tmp;
		tmp = array[a];
		array[a] = array[b];
		array[b] = tmp;
	}
	for (int i = 1; i < w + 1; i++) {
		cout << array[i] << endl;
	}
	return 0;
}
