#!/usr/local/bin/ruby
while line=gets
   n=line.to_i
   m=gets.to_i
   arr=(1..n).to_a
   m.times{
      rec=gets.split(",")
      x,y=rec[0].to_i,rec[1].to_i
      tmp=arr[x-1]
      arr[x-1]=arr[y-1]
      arr[y-1]=tmp
   }
   puts arr
end