#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)

int w,n;
int ans[50];
int a,b;

int main(){
	cin>>w>>n;
	rep(i,w){
		ans[i+1] = i+1;
	}
	rep(i,n){
		char t;
		int tmp;
		cin>>a>>t>>b;
		tmp = ans[a];
		ans[a] = ans[b];
		ans[b] = tmp;
	}
	rep(i,w){
		cout<<ans[i+1]<<endl;
	}
	return 0;
}