while gets
  w = $_.to_i
  n = gets.to_i
  a = (1..w).to_a

  #a = Array.new
  #for i in 1..w
  #  a.push(i)
  #end

  for i in 1..n
    s = gets.split(",")
    x = s[0].to_i - 1
    y = s[1].to_i - 1
    a[x], a[y] = a[y], a[x]
  end

  puts a

  #for i in 0...w
  #  puts a[i]
  #end
end