w = gets.to_i
n = gets.to_i
d = Array.new
w.times do |i|
  d.push(i+1)
end
n.times do
  line = gets
  s = line.split(",").map(&:to_i)
  d[s[0]-1], d[s[1]-1] = d[s[1]-1], d[s[0]-1]
end
w.times do |i|
  puts d[i]
end