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

data = (0...w).map { |i| i}
for i in (0...n)
    a,b = gets.chomp.split(",").map {|k| k.to_i - 1}
    tmp = data[a]
    data[a] = data[b]
    data[b] = tmp
end

data.each do |i|
    puts i + 1
end
