#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int w;
	cin >> w;

	vector<int> lines;
	for(int i = 1; i <= w; i++)
		lines.push_back(i);

	int n;
	cin >> n;

	for(int i = 0; i < n; i++)
	{
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(lines[a-1], lines[b-1]);
	}

	for(auto line : lines)
		cout << line << endl;

	return 0;
}