#include <iostream>
using namespace std;

int main() {
int w,n;
cin>>w>>n;
int tate[w+1];
for (int k=0;k<=w;k++){
	tate[k]=k;
}
for (int l=0;l<n;l++){
	int a,b,c;
	char pp;
	cin>>a>>pp>>b;
	c=tate[a];
	tate[a]=tate[b];
	tate[b]=c;
}
for (int ll=1;ll<=w;ll++){
	cout<<tate[ll]<<endl;
}
	return 0;
}