#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef vector <int> vi;

int str2int(string text){
    stringstream ss;
    ss<<text;
    int tmp;
    ss>>tmp;
    return tmp;
}

int main(void){
    int w=0, n;
	cin>>w;
	vi x(w);
	for (int i=0; i<w; i++)
		x[i] = i+1;

	cin>>n;
	for (int i=0; i<n; i++){
		string text;
		cin>>text;
		string::size_type index = text.find( "," );

		int a, b;
		a = str2int(text.substr(0, index));
		b = str2int(text.substr(index+1));
		swap(x[a-1], x[b-1]);
	}

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