#include <iostream>
using namespace std;

int main()
{
	int w, n, z;
	char c[30];
	int N[30];
	int a[30], b[30];
	cin >> w >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> c[i] >> b[i];
	}
	for (int i = 1; i <= w; i++)
	{
		N[i] = i;
	}
	for (int i = 0; i < n; i++)
	{
		z = N[a[i]];
		N[a[i]] = N[b[i]];
		N[b[i]] = z;
	}
	for (int i = 1; i <= w; i++)
	{
		cout << N[i] << endl;
	}
}
