#include <iostream>
using namespace std;

int swap(int* x, int* y){
	int tmp = *y;
	*y = *x;
	*x = tmp;
}
	
int main(){
	int w, n, array[31];
    int a, b;
    
    char sep;
    
	for(int i=1; i<=30; i++){
		array[i] = i;
	}
	
	cin >> w;
	cin >> n;
	
	while(0<n){
		cin >> a >> sep >> b;
		
		swap(&array[a], &array[b]);
		--n;
	}
	
	for(int j=1; j<=w; j++){
		cout << array[j] << endl;
	}
	return 0;
}