w = gets.chomp.to_i  # pos number(yoko)
n = gets.chomp.to_i  # bar number(tate)

pos = [*0..w]

1.upto(n){|i|
  from,to = gets.chomp.split(',').map{|x| x.to_i}
  kari = pos[to]
  pos[to] = pos[from]
  pos[from] = kari
}
puts pos.reject{|x|x==0}