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

nums = []
for i in 1..w
   nums[i] = i
end

a = []
b = []

for i in 1..n
   ln = gets
   a[i], b[i] = ln.chomp.split(",")
   a[i], b[i] = a[i].to_i, b[i].to_i
end

for i in 1..n
   tmp = nums[a[i]]
   nums[a[i]] = nums[b[i]]
   nums[b[i]] = tmp
end

for i in 1..w
   puts nums[i]
end
