#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main( void )
{
	int w, n;
	cin >> w >> n;
	vector <int> S(w);
	for ( int i = 0; i < w; i++ )
		S[i] = i+1;

	for ( int i = 0; i < n; i++ )
	{
		int a, b;
		char c;
		cin >> a >> c >> b;
		swap( S[a-1], S[b-1] );
	}

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

	return 0;
}