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

void swap( int &a, int &b )
{
 	int t;
	t = a;
	a = b;
	b = t;
	
	return;
}

int main()
{
	int w, n;
	int ans[30];
	std::vector<std::pair<int,int> > vec;
	
	scanf( "%d", &w );
	scanf( "%d", &n );
	for( int i = 0; i < n; i++ ){
		int a, b;
		scanf( "%d,%d", &a, &b );
		vec.push_back( std::make_pair<int,int>( a, b ) );
	}
	
	for( int i = 0; i < w; i++ ) ans[i] = i + 1;
	
	for( std::vector<std::pair<int,int> >::iterator it = vec.begin(); it != vec.end(); it++ ){
		swap( ans[ it->first - 1 ], ans[ it->second - 1 ] );	
	}
	
	for( int i = 0; i < w; i++ ){
	 	std::cout << ans[i] << std::endl;
	}

 	return 0;
}