#include <iostream>
#include <vector>
#include <string>
#include <strstream>
using namespace std;

int main()
{
	int w,n;
	cin >> w >> n;
	vector<int> line;
	for(int i=0; i<w; ++i)
	{
		line.push_back(i);
	}

	for(int i=0; i<n; ++i)
	{
		string str;
		cin >> str;
		int dot = str.find(',');
		string numa = str.substr( 0, dot );
		string numb = str.substr( dot+1, str.size()-1 );
		int A,B;
		istrstream( numa.data() ) >> A;
		istrstream( numb.data() ) >> B;
		--A;
		--B;
		int x = line[A];
		line[A] = line[B];
		line[B] = x;
	}

	for(int i=0; i<w; ++i)
	{
		cout << line[i]+1 << '\n';
	}
}