w = gets.to_i
n = gets.to_i
data = Array.new
w.times{|i|
	data << i+1
}
n.times{|i|
	wide = gets
	ab = wide.split(",")
	a = ab[0].to_i - 1
	b = ab[1].to_i - 1
	safe = data[a]
	data[a] = data[b]
	data[b] = safe
}
w.times{|i|
	p data[i]
}