#include<iostream>
#define MAX_W 30
#define MAX_N 30
using namespace std;

typedef pair<int, int> P;
P line[MAX_N + 1];
int n, w;
char comma;
int result[MAX_W + 1];

void input()
{
	cin >> w >> n;
	for (int i = 1; i <= n; i++)
		cin >> line[i].first >> comma >> line[i].second;
}

void solve()
{
	int pos;
	for (int i = 1; i <= w; i++)
	{
		pos = i;
		for (int j = 1; j <= n; j++)
		{
			if (line[j].first == pos)
				pos = line[j].second;
			else if (line[j].second == pos)
				pos = line[j].first;
		}
		result[pos] = i;
	}
}

void print()
{
	for (int i = 1; i <= w; i++)
		cout << result[i] << endl;
}

int main()
{
	input();
	solve();
	print();
	return 0;
}