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

int main() {
	int w, n, i, x, y, z;
	char str[10], *a, *b;
	cin >> w >> n;
	vector<int> A(w);
	for (i = 0; i < w; i++) A[i] = i + 1;
	for (i = 0; i < n; i++) {
		cin >> str;
		a = strtok(str, ","); 
		x = atoi(a);
		b = strtok(NULL, ","); 
		y = atoi(b);
		z = A[x - 1];
		A[x-1] = A[y-1]; A[y-1] = z;
	}
	for (i = 0; i < w; i++) cout << A[i] << endl;
	return 0;
}