#include <iostream>
using namespace std;

int main()
{
	int w, n;
	int a[30], b[30];
	
	cin >> w >> n;

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

	for (int i = 0; i < w; i++) {
		int g = i + 1;

		for (int j = n - 1; j >= 0; j--) {
			if (a[j] == g)
				g = b[j];
			else if (b[j] == g)
				g = a[j];
		}

		cout << g << endl;
	}

	return 0;
}
