#include<iostream>
using namespace std;

int main(){
	int w, n;
	int a[30], b[30];
	int p, q, r;
	int base[31];

	base[0] = 0;
	w = 0; n = 0;

	cin >> w;
	cin >> n;

	for (int i = 0; i <= w; i++){
		base[i] = i;
	}
	for (int i = 0; i<n; i++){
		cin >> a[i] >> b[i];
	}

	for (int i = 0; i<n; i++){
		p = a[i]; q = b[i];
		r = base[p];
		base[p] = base[q];
		base[q] = r;
	}

	for (int i = 1; i <= w; i++){
		cout << base[i];
		if (i != w){
			cout << " ";
		}
		if (i == w){
			cout << "\n";
		}
	}

	return 0;
}