#coding:utf-8


w = gets.chomp.to_i
n = gets.chomp.to_i
list = Array.new
wire = Array.new

w.times{|i|
	wire << i+1
}


n.times{|i|
	str = gets.chomp.split(',').map(&:to_i)
	list << str
	a,b = str[0], str[1]

	

	wire[a-1],wire[b-1] = wire[b-1],wire[a-1]

}

puts wire