#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int w, n;
	cin >> w >> n;
	vector<int> Pos(w + 1);
	vector<P> Vec(n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d,%d", &Vec[i].first, &Vec[i].second);
	}
	for(int i = 1; i <= w; ++i)
	{
		int pos = i;
		for(int j = 0; j < n; ++j)
		{
			if(Vec[j].first == pos)
			{
				pos = Vec[j].second;
			}
			else if(Vec[j].second == pos)
			{
				pos = Vec[j].first;
			}
		}
		Pos[pos] = i;
	}
	for(int i = 1; i <= w; ++i)
	{
		cout << Pos[i] << endl;
	}
}

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