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

array = []
a = []
b = []

for j in 1..w
  array[j] = j
end

for i in 1..n
  a, b =gets.chomp.split
  a = a.to_i
  b = b.to_i

  for k in 1..w
    if a == k
      x = array[b]
      array[b] = array[k]
      array[k] = x
    end
  end  
end

for s in 1..w
    puts array[s]
end