w = gets.to_i
n = gets.to_i
array = Array.new(n)
for i in 1..n
	set = gets.to_s
	array[i] =  set.split(",")
	array[i][0] = array[i][0].to_i
	array[i][1] = array[i][1].to_i
end 
answer = Array[0]
for i in 1..w
	answer << i
end
for i in 1..n
	temp = answer[array[i][0]]
	answer[array[i][0]] = answer[array[i][1]]
	answer[array[i][1]] = temp
end
puts answer[1..w]