#include <iostream>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	int w,n,a[30];
	scanf("%d%d",&w,&n);
	rep(i,w) a[i]=i+1;
	rep(i,n){
		string s;
		cin >> s;
		swap(a[s[0]-'1'],a[s[2]-'1']);
	}
	rep(i,w) printf("%d\n",a[i]);
	return 0;
}