w = gets.to_i
n = gets.to_i

n_list = []
n.times.each do
  st = gets.split(/\s/)
  n_list << [st[0].to_i, st[1].to_i]
end

answers = []
1.upto(w).each do |i|
  current_w = i
  n_list.each do |n_line|
    if current_w == n_line[0]
      current_w = n_line[1]
    elsif current_w == n_line[1]
      current_w = n_line[0]
    end
  end
  answers[current_w - 1] = i
end
puts answers