import std.stdio,std.string,std.array,std.conv,std.algorithm;
void main(){
	string[] lines;
	lines.length = to!int( readln().chomp() );
	for( int i=0 ; i<lines.length ; i++ ){
		lines[i]=to!string(i+1);
	}
	
	auto reads = to!int( readln().chomp() );
	for( int i=reads; 0<i; i-- ){
		auto change = split( readln().chomp(), "," );
		auto x = to!int(change[0])-1;
		auto y = to!int(change[1])-1;
		swap( lines[x], lines[y] );
	}
	writeln( join( lines[0..$] ) );
}