w = gets.to_i
n = gets.to_i
arr = []

for i in 0...w
  arr[i] = i + 1
end

n.times do
  a, b = gets.split(",").map(&:to_i)
  arr[a - 1], arr[b - 1] = arr[b - 1], arr[a - 1]
end

for i in 0...w
  p arr[i]
end