n = gets.to_i
quakes = (1..n).map { gets.split.map(&:to_i) }.sort
accum = [0]
quakes.each {|t, a| accum << accum[-1] + Math.log10((10 - a) / 10.0) }
q = gets.to_i
q.times do
  l, r = gets.split.map(&:to_i)
  i = (0..quakes.size-1).bsearch {|i| l < quakes[i][0] } || quakes.size
  j = ((0..quakes.size-1).bsearch {|i| r < quakes[i][0] } || quakes.size) - 1
  p 10 ** (9 + (accum[j + 1] - accum[i]))
end

