#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int w,n;
	
	cin >> w >> n;
	int a[30];
	for ( int i = 1; i <= 30; i++ )
		a[i - 1] = i;
	int ai,bi;
	for ( int i = 0; i < n; i++ ) {
		scanf ("%d,%d",&ai,&bi);
		swap ( a[ai-1],a[bi-1] );
	}
	for ( int i = 0; i < w; i++ )
		cout << a[i] << endl;
	
	return 0;
}