#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;


int main(){
	int stick[40];
	int n,q;
	string pair;
	cin>>n;
	for(int i=0;i<n;i++){
		stick[i]=i+1;
	}
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>pair;
		swap(stick[pair[0]-'0'-1],stick[pair[2]-'0'-1]);
	}
	for(int i=0;i<n;i++){
		cout<<stick[i]<<endl;
	}
}