#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

double dist(double x1, double y1, double x2, double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){
	int w, n;

	char bar[10];
	vector<int> a(31);
	const char delim = ',';
	int left, right;

	for(int i = 1; i <= 30; i++){
		a[i] = i;
	}

	cin >> w >> n;

	while(n--){
		cin >> bar;
		left = atoi(strtok(bar, &delim));
		right = atoi(strtok(NULL, &delim));
		swap(a[left], a[right]);
	}

	for(int i = 1; i <= w; i++){
		cout << a[i] << endl;
	}

	return 0;
}