#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int w;
	int n;
	int number[30] = {0};
	int kari;
	int a, b;
	char c;

	cin >> w;
	cin >> n;

	for(int i = 0; i < w; i++) {
		number[i] = i + 1;
	}

	for(int i = 0; i < n; i++) {
		cin >> a >> c >> b;
		kari = number[a-1];
		number[a-1] = number[b-1];
		number[b-1] = kari;
	}

	for(int i = 0; i < w; i++) {
		printf("%d\n", number[i]);
	}

	return 0;
}