#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define ll long long int

#define rep(p,q) for(int i = p; i < q;i++)


//11

int main(void) {
	int w, n;
	cin >> w >> n;
	int line[30];
	rep(0, 30) line[i] = i+1;
	rep(0, n) {
		int a, b;
		string comma;
		cin >> a >> comma;
		b = stoi(comma.substr(1));
		int swap = line[a - 1];
		line[a - 1] = line[b - 1];
		line[b - 1] = swap;
	}
	rep(0, w) {
		cout << line[i] << endl;
	}
}

