#include <iostream>
#include <string>
#include <stack>
using namespace std;


int main(){
	int w;
	int n;
	int a[30];
	int b[30];
	int c[30];
	cin >> w;
	cin >> n;
	int x;
	int y;
	int z;
	for (int i = 1; i <= w; i++){
		c[i - 1] = i;
	}
	for (int i = 0; i < n; i++){
		char t;
		cin >> a[i] >> t >> b[i];

		x = a[i];
		y = b[i];
		z = c[x - 1];
		c[x - 1] = c[y - 1];
		c[y - 1] = z;
	}
	for (int i = 0; i < w; i++){
		cout << c[i] << endl;
	}
	return 0;
}
