w = gets.chomp.to_i
n = gets.chomp.to_i
ary_swap = Array.new
n.times { ary_swap << gets.chomp.split(",").map(&:to_i) }

answer = Array.new

(1..w).each do |i|
  present_position = i
  ary_swap.each do |ary_swap_temp|
    next unless ary_swap_temp.include?(present_position)
    present_position = ary_swap_temp[1 - ary_swap_temp.index(present_position)]
  end
  answer[present_position - 1] = i
end

print answer.join("\n")
print "\n"