w = gets.to_i

lines = []
result = []
gets.to_i.times { lines << gets.split(',').map(&:to_i) }

1.upto(w) do |i|
  position = i
  lines.each do |line|
    if line[0] == position
      position = line[1]
      next
    end

    if line[1] == position
      position = line[0]
      next
    end
  end

  result[position-1] = i
end

result.each { |r| puts r }

