#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int tate[31],yoko;
	int tates;
	char neko;
	scanf("%d%d",&tates,&yoko);
	for(int i = 1;i<=tates;i++)//縦に０からtates番まで入る
	{
		tate[i] = i;
	}
	int amida1,amida2;
	int a = 0;
	for(int j = 0;j<yoko;j++)
	{
		scanf("%d%c%d",&amida1,&neko,&amida2);
		a = tate[amida1];
		tate[amida1] = tate[amida2];
		tate[amida2] = a;
	}
	for(int i = 1;i <=tates;i++)
	{
		printf("%d\n",tate[i]);
	}
	return 0;
}