#include<iostream>
#include <algorithm>
using namespace std;

int main(){
	int amida[30];
	for (int i = 0; i < 30; i++){
		amida[i] = i + 1;
	}
	int n, w;
	int a, b;

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