#encoding:utf-8
num_of_amida = gets.chomp
n = 1
amida = []
while n <= num_of_amida.to_i
 amida.push n
 n += 1
end

num_of_change = gets.chomp
change = Array.new(num_of_change.to_i)

i = 0
while i < change.length
 change_num = gets.chomp
 change[i] = change_num
 i += 1
end

i = 0
while i < change.length
 x = change[i][0].to_i
 y = change[i][2].to_i
 amida[x-1],amida[y-1] = amida[y-1],amida[x-1]
 i += 1
end

i = 0
while i < amida.length
 puts amida[i]
 i += 1
end