#include <iostream>
#include <string>
using namespace std;

int main() {
	int w, n, x, y;
	string str;
	cin >> w >> n;
	int a[31];
	for (int i = 0; i <= w; i++) {
		a[i] = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> str;
		x = str[0];
		y = str[2];
		cout << x << y << endl;
		int tmp = a[x-48];
		a[x-48] = a[y-48];
		a[y-48] = tmp;
	}
	for (int i = 1; i <= w; i++) {
		cout << a[i] << endl;
	}
	return 0;
}