w = gets.chomp.to_i
n = gets.chomp.to_i

change = []

for i in (0...n)
        change[i] = gets.chomp.split(",")
        change[i][0] = change[i][0].to_i - 1
        change[i][1] = change[i][1].to_i - 1
end


data = []
for i in (0...w)
        data[i] = i + 1
end


for i in (0...n)
        data[change[i][0]], data[change[i][1]] = data[change[i][1]], data[change[i][0]]
end

puts data

