w = gets.to_i
n = gets.to_i
array = Array.new
i = 0
n.times do
  array[i], array[i+1] = gets.split(",").map(&:to_i)
  i+=2
end
result = Array.new
w.times do |j|
  result[j] = j
end
i = 0
n.times do
  result[array[i]-1], result[array[i+1]-1] = result[array[i+1]-1], result[array\
[i]-1]
  i+=2
end
result.map{|k| k+1}
w.times do |i|
  puts result[i] + 1
end