#include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }

int main() {
	int W,N;
	vector<int> nums;

	cin >> W;
	rep(i,W) {
		nums.push_back(i+1);
		//cout << i+1;
	}
	//cout << endl;

	string a_str;
	cin >> N;
	rep(i,N) {
		cin >> a_str;
		int left = a_str[0] - '0';
		int right = a_str[2] - '0';
		int tmp = nums[left-1];
		nums[left-1] = nums[right-1];
		nums[right-1] = tmp;
	}
	rep(i,nums.size()) {
		cout << nums[i] << endl;
	}

	return 0;
}