#include<iostream>
#include<cstdio>
using namespace std;


#define MAX 30


int in[MAX];

int w , n;

int Left , Right;


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

	for (int i = 0; i < w; i++)
	{
		in[i] = i + 1;
	}

	for (int i = 0; i < n; i++)
	{
		scanf("%d,%d" , &Left , &Right);

		int tmp = in[Left - 1];
		in[Left - 1] = in[Right - 1];
		in[Right - 1] = tmp;
	}

	for (int i = 0; i < w; i++)
	{
		cout << in[i] << endl;
	}

	return 0;
}