#include <iostream>
#include <algorithm>

using namespace std;

int main(){

	int w,n;
	cin >> w >> n;
	int line [w];

	for(int i = 0; i < w; i++){
		line[i] = i+1;
	}

	char cmd[4];
	for(int i = 0; i < n; ++i){
		cin >> cmd;
		swap(line[cmd[0]-'0'-1], line[cmd[2]-'0'-1]);
	}

	for(int i = 0; i < w; ++i){
		cout << line[i] << endl;
	}

	return 0;
}