#include<iostream>
using namespace std;

int main() {
	int w, n;
	int a[30];
	cin >> w >> n;
	for (int i = 0;i < w;i++) {
		a[i] = i + 1;
	}
	for (int i = 0;i < n;i++) {
		int p, q;
		char s;
		cin >> p >> s >> q;
		swap(a[p - 1], a[q - 1]);
	}
	for (int i = 0;i < w;i++)cout << a[i] << endl;
}
