#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#define rep(x,to) for(x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;




int main(void){

int ww,w[32];	
int nn,ra,rb,i;
char cn;
	cin >> ww;
	cin >> nn;
	
	rep(i,ww) w[i]=i+1;
	rep(i,nn){
		cin >> ra >> cn >> rb;
		swap(w[ra-1],w[rb-1]);
	}
	rep(i,ww) cout << w[i] << endl;
	return 0;
}