class Array
  def swap!(a, b)
    self[a], self[b] = self[b], self[a]
  end
end

w=gets.to_i
n=gets.to_i
ans=Array.new(w)
w.times{|i|
	ans[i]=i+1
}
n.times{
	input=gets.split(",")
	a=input[0].to_i
	b=input[1].to_i
	ans.swap!(a-1,b-1)
}
for j in 0..w-1 do
	puts ans[j]
end 
