#include <bits/stdc++.h>

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;



int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int w = 0, n = 0;
	char a, b, temp;
	std::cin >> w >> n;

	std::vector<int> A(w + 1);
	std::iota(A.begin(), A.end(), 0);

	for (int i = 0; i < n; i++) {
		std::cin >> a >> temp >> b;
		std::swap(A[a - '0'], A[b - '0']);
	}

	for_each(A.begin() + 1, A.end(),
		[](int &i) {
		std::cout << i << std::endl;
	}
	);

}