#include <iostream>
using namespace std;
int main(){
	int w,n,a[31],b[31],last[31];
	char f;
	cin>>w>>n;
	for(int i=1;i<n+1;i++){
		cin>>a[i]>>f>>b[i];
	}
	for(int i=1;i<w+1;i++){
		int l=i;
		//cout <<l<<endl;
		for(int j=1;j<n+2;j++){
			if(l==a[j]){
				l=b[j];
				//cout<<a[j]<<" "<<l<<endl;
			}
			else if(l==b[j]){
				l=a[j];
				//cout<<b[j]<<" "<<l<<endl;
			}
			else if(j==n+1){
				last[l]=i;
				//cout <<last[l]<<" "<<l<<endl;
			}
		}
	}
	for(int i=1;i<w+1;i++){
		cout<<last[i]<<endl;
	}
}
