#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
std::vector<int> change (std::vector<int> v,int i, int j) {
	int tmp = v[i-1];
	v[i-1] = v[j-1];
	v[j-1] = tmp;
	return v;
}
int main () {
	int w,n;
	cin >> w >> n;
	std::vector<int> num(w);
	for(int i = 0; i < w; i++){
		num[i] = i+1;
	}
	for(int i = 0; i < n; i++){
		int a,b;
		scanf("%d,%d",&a,&b);
		num = change(num,a,b);
	}
	for(int i = 0; i < w; i++) {
		cout << num[i]<< endl;
	}
}
