#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int w, n, ans[31];
	cin >> w >> n;
	for (int i = 0; i <= 30; i++)
		ans[i] = i;
	for (int i = 0; i < n; i++) {
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap(ans[a], ans[b]);
	}
	for (int i = 1; i <= 30; i++)
		cout << ans[i] << endl;
}
