#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int ans[31]={};
int a[31],b[31];

int main() {

	int w,n;
	cin>>w;
	cin>>n;
	char c=',';
	rep(i,n)cin>>a[i]>>c>>b[i];
	for(int i=1; i<w+1; i++){
		int x=i;
		rep(j,n){
			if(x==a[j])x=b[j];
			else if(x==b[j])x=a[j];
		}
		ans[x]=i;
	}
	rep(i,w)cout<<ans[i+1]<<endl;

	return 0;
}

