#include<iostream>
#include<cstdio>
using namespace std;
#define F(I,J,N) for(int I=J;I<N;I++)

void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(){
	int *l;
	int p,q;
	int x,y;
	while(cin>>p){
		l=new int[p];
		F(i,0,p) l[i]=i+1;
		cin>>q;
		F(i,0,q){
			scanf("%d,%d",&x,&y);
			swap(&l[x-1],&l[y-1]);
		}
		F(i,0,p) cout<<l[i]<<endl;
		delete []l;
	}
}