//0011 Drawing Lots
//¢íÉ­¶ðø±¤I
//cüÌ{wA¡{Ì{hª^¦çêA
//ã©çÉhÂÌ¡üÌêª^¦çê½Æ«A±Ì¡üðÊßµ½Æ«ÌcüÌÔð¦æ
//È¨¡üÌîñÍA¡üªcüÌÊua,bÆÂÈªÁÄ¢éÆ·éÆA"a,b"Å\³êé
//w <= 30, h <= 30ª½³êéÆ·é

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

int main(void)
{
	const int N = 30;
	int w, h;
	int i;
	int a, b;

	int amida[N+1];	//âèÍ1©çnßÄ¢é©ç í¹é©@0ÈñÄÈ©Á½

	cin >> w >> h;

	//¡üªÈ¢Æ«Ìóµ
	for(i = 1; i <= w; i++)
		amida[i] = i;

	for(i = 0; i < h; i++)
	{
		//','ª´êÄ¢éÌÅòÎµÜµå¤
		char dummy;
		cin >> a >> dummy >> b;
		//¡üª éÆA½ÎÉÈèÜ·
		swap(amida[a], amida[b]);
	}
	
	for(i = 1; i <= w; i++)
	{
		cout << amida[i] << endl;
	}

	return 0;
}