class Amidakuji
   def initialize(w)
	  @array = []
	  (1..w).each {|each| @array.push(each)}
   end

   def replace(x,y)
	  #?????????x????????¨y???????????\???????????????x,y???Array?????????
	  tempo = @array[y]
	  @array[y] = @array[x]
	  @array[x] = tempo
   end

   def puts_array
	  @array.each do |i|
		 puts i.to_s
	  end
   end
end

verti = gets.to_i
a = Amidakuji.new(verti)
hori = gets.to_i
hori.times do
   ex = gets.split(',').map(&:to_i)
   a.replace(ex[0]-1, ex[1]-1)
end
a.puts_array