#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
	int ary[31];
	int n, w;

	cin >> w >> n;
	for (int i = 1; i <= w; i++)
	{
		ary[i] = i;
	}
	for (int i = 0; i < n; i++)
	{
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(ary[a], ary[b]);
	}
	for (int i = 1; i <= w; i++)
	{
		cout << ary[i] << endl;
	}

	return 0;
}