#include <iostream>
#include <utility>

using namespace std;

int main(void){
	int w,n,*num,a,b,tmp;
	pair<int,int> *ln;
	char nul;

	cin >> w >> n;
	num = new int[w+1];
	ln = new pair<int,int>[n];

	for(int i=0;i<n;i++){
		cin >> a >> nul >> b;
		ln[i]=make_pair(a,b);
	}

	for(int i=1;i<=w;i++){
		tmp=i;
		for(int j=0;j<n;j++)
			tmp=tmp!=ln[j].first?tmp!=ln[j].second?tmp:ln[j].first:ln[j].second;
		num[tmp]=i;
	}
	for(int i=1;i<=w;i++)
		cout << num[i] << endl;

	delete [] ln;
	delete [] num;
	return 0;
}