class Ami

  def initialize(f,w) #[[from0,to0], [from1,to1],...[from(n-1),to(n-1]]
    @bar = f
    @w = w
    @n = f.length
  end

  def towhere(from)
    now = from
    0.upto(@n-1){|j|
      if @bar[j].first == now then
        now = @bar[j].last
      elsif @bar[j].last == now then
        now = @bar[j].first
      end
    }
    return now
  end

end

bar = []
w = gets.chomp.to_i  # pos number(yoko)
n = gets.chomp.to_i  # bar number(tate)
0.upto(n-1){|i|
  from,to = gets.chomp.split(',').map{|x| x.to_i}
  bar.push([from,to])
}

ami = Ami.new(bar,w)

p=[]
1.upto(w){|j|
  p[ami.towhere(j)]=j
}
p.shift
puts p