class DrawingLots
  def initialize(width, switch_ary)
    @results = (1..width).to_a
    switch_ary.each do |data|
      tmp                   = @results[data[1] - 1]
      @results[data[1] - 1] = @results[data[0] - 1]
      @results[data[0] - 1] = tmp
    end
  end

  attr_accessor :results

  def all_result
    return @results
  end
end

width = gets.to_i
switch_ary = []
gets.to_i.times do
  switch_ary << gets.split(",").map(&:to_i)
end

puts DrawingLots.new(width, switch_ary).all_result.join(" ")