#include<iostream>

using namespace std;

int main()
{
	int w;
	int n;

	cin >> w >> n;
	int ws[w+1];

	for(int i = 1; i <= w; ++i)ws[i] = i;

	for(int i = 0; i < n; ++i){
		int a,b;
		int tmp;
		char d;
		cin >> a >> d >>b;
		tmp   = ws[a];
		ws[a] = ws[b];
		ws[b] = tmp;
	}
	
	for(int i = 1; i <= w; ++i)cout << ws[i] << endl;

	return 0;
}