import std.stdio,
			 std.array,
			 std.conv,
			 std.string,
			 std.algorithm;

void main() {
	int bars[];
	int w = readln.chomp.to!int;
	bars = new int[w+1];
	foreach (int i; 1..(w+1)) {
		bars[i] = i;
	}
	int n = readln.chomp.to!int;
	foreach (int i; 0..n) {
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(bars[a], bars[b]);
	}
	foreach (int i; 1..w+1) {
		writeln(bars[i]);
	}
}