#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
	int w;
	int n;
	int ary[30];

	cin >> w >> n;
	for (int i = 1; i <= w; i++){
		ary[i] = i;
	}

	for (int i = 0; i < n; i++){
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(ary[a], ary[b]);
	}

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


	return 0;
}