### constant

W = 100
H = 50
D = 30

V = W * H * D

### classes

class SECT
  attr_accessor :xl, :xr, :hl, :hr, :am, :wh, :min_h

  def initialize(xl, xr, hl, hr, am)
    @xl = xl
    @xr = xr
    @hl = hl.to_f
    @hr = hr.to_f
    @am = am.to_f
    @wh = 0.0
    @min_h = (@hl < @hr) ? @hl : @hr
  end

  def dh
    @am / ((@xr - @xl) * D)
  end

  def dt_full
    return Float::INFINITY if @am == 0.0
    (@min_h - @wh) / dh()
  end

  def merge(sct)
    if @min_h != sct.min_h || @wh != sct.wh
      p ['Error', self, sct]
    end
    @xr = sct.xr
    @hr = sct.hr
    @am += sct.am
    @min_h = (@hl < @hr) ? @hl : @hr
  end
end

### main

dn = gets.to_i

dn.times do
  n = gets.to_i
  brds = [[0, H]] + n.times.map{gets.split.map(&:to_i)} + [[W, H]]

  scts = []
  for i in (0..n)
    b0x, b0h = brds[i]
    b1x, b1h = brds[i + 1]
    scts << SECT.new(b0x, b1x, b0h, b1h, 0.0)
  end

  m = gets.to_i
  m.times do
    fi, ai = gets.split.map(&:to_i)
    for sct in scts
      if sct.xl <= fi && fi <= sct.xr
        sct.am += ai
        break
      end
    end
  end
  #p scts

  l = gets.to_i
  ovs = []
  for i in (0...l)
    xi, ti = gets.split.map(&:to_i)
    ovs << [ti, xi, i]
  end
  ovs.sort!
  #p ovs

  t0 = 0.0
  ohs = []

  while ! ovs.empty?
    min_dt = Float::INFINITY
    min_i = nil

    for i in (0...scts.length)
      dt_fi = scts[i].dt_full
      if min_dt > dt_fi
        min_dt = dt_fi
        min_i = i
      end
    end
    #p scts
    #p [min_dt, min_i]

    t1 = t0 + min_dt

    while ! ovs.empty? && ovs[0][0] <= t1
      ti, xi, i = ovs.shift

      for j in (0...scts.length)
        sctj = scts[j]
        if sctj.xl <= xi && xi <= sctj.xr
          ohs[i] = sctj.wh + sctj.dh * (ti - t0)
          break
        end
      end
    end
    break if ovs.empty?

    t0 = t1

    for i in (0...scts.length)
      scti = scts[i]
      if i == min_i
        scti.wh = scti.min_h
      else
        scti.wh = scti.wh + scti.dh * min_dt
      end
    end

    if scts.length == 1
      scts[0].am = 0.0
      next
    end

    min_sct = scts[min_i]
    if min_sct.hl < min_sct.hr
      sct0 = scts[min_i - 1]
      if min_sct.min_h == sct0.min_h && sct0.wh == sct0.min_h
        sct0.merge(min_sct)
        scts.delete_at(min_i)
      else
        sct0.am += min_sct.am
        min_sct.am = 0.0
      end
    else
      sct1 = scts[min_i + 1]
      if min_sct.min_h == sct1.min_h && sct1.wh == sct1.min_h
        min_sct.merge(sct1)
        scts.delete_at(min_i + 1)
      else
        sct1.am += min_sct.am
        min_sct.am = 0.0
      end
    end
  end

  ohs.each{|oh| puts "%.6f" % oh}
end