w = gets.to_i
arr = Array.new(w)
0.upto(arr.size-1) do |i|
    arr[i] = i+1
end
gets.to_i.times do
    a, b = gets.split(",").map(&:to_i)
    a -= 1; b -= 1
    arr[a], arr[b] = arr[b], arr[a]
end
puts arr