#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

int solve(){
  int n, m, q;
  pair<int,int> wall[20];
  pair<pair<int,int>, int> query[20];
  int sumf[SIZE] = {};
  
  scanf("%d", &n);
  
  for(int i=0;i<n;i++){
    int b, h;
    scanf("%d%d", &b, &h);
    wall[i] = {b, h};
  }
  wall[n] = {0, 50};
  wall[n+1] = {100, 50};

  n += 2;
  
  sort(wall, wall+n);

  scanf("%d", &m);
  
  for(int i=0;i<m;i++){
    int f, a;
    scanf("%d%d", &a, &f);

    for(int j=0;j<n-1;j++){
      if (wall[j].first <= a && a <= wall[j+1].first) {
        sumf[j] += f;
        break;
      }
    }
  }
  
  scanf("%d", &q);

  for(int i=0;i<q;i++){
    int p, t;
    scanf("%d%d", &p, &t);
    query[i] = {{t, p}, i};
  }

  sort(query, query+q);

  double curT = 0;
  double water[20] = {}, ans[20] = {};
  int r = 0;

  bool isfull[20] = {};
  
  while(1){
    int pos = -1;
    double nextT = INF;
    
    for(int i=0;i<n-1;i++){
      int minW = min(wall[i].second, wall[i+1].second);
      int dw = wall[i+1].first - wall[i].first;
      if (sumf[i] == 0) continue;
      double r = (double)(minW * 30 * dw -  water[i]) / sumf[i];
      assert(r >= -1e-8);
      if (nextT > curT + r){
        nextT = curT + r;
        pos = i;
      }
    }

    //debug(nextT);
    while(r < q && query[r].first.first <= nextT){
      int p = query[r].first.second;
      int t = query[r].first.first;
      int qid = query[r].second;
      r++;
      for(int i=0;i<n-1;i++){
        if (wall[i].first <= p && p <= wall[i+1].first) {
          int dw = wall[i+1].first - wall[i].first;
          ans[qid] = ((t - curT) * sumf[i] + water[i]) / dw / 30;
          break;
        }
      }
    }

    if (r == q) break;
    assert(pos != -1);
    assert(pos < n-1);

    for(int i=0;i<n-1;i++){
      double dt = nextT - curT;
      water[i] += sumf[i] * dt;
    }
    
    //marge
    /*
    if(n == 2){
      curT = nextT;
      continue;
    }
    */

    for(int i=0;i<n-1;i++){
      /*
      debug(i);
      debug(wall[i].first);
      debug(wall[i+1].first);
      debug(wall[i].second);
      debug(wall[i+1].second);
      debug(water[i]);
      debug(isfull[i]);
      */
      assert(water[i] - 1e-5 < min(wall[i].second, wall[i+1].second) * 30 * (wall[i+1].first - wall[i].first) );
    }
    
    isfull[pos] = true;
    
    if(wall[pos].second < wall[pos+1].second){
      
      if (isfull[pos-1] && wall[pos-1].second > wall[pos].second){
        sumf[pos-1] += sumf[pos];
        water[pos-1] += water[pos];
        wall[pos] = wall[pos+1];
        for(int i=pos;i<n-2;i++){
          sumf[i] = sumf[i+1];
          isfull[i] = isfull[i+1];
          wall[i+1] = wall[i+2];
          water[i] = water[i+1];
        }
        n--;
        isfull[pos-1] = false;
      } else {
        for(int i=pos-1;i>=0;i--){
          if(wall[i-1].second > wall[i].second || !isfull[i]){
            sumf[i] += sumf[pos];
            break;
          }
        }
        sumf[pos] = 0;
      }
      
    } else {

      if (isfull[pos+1] && wall[pos+1].second < wall[pos+2].second){
        sumf[pos+1] += sumf[pos];
        water[pos+1] += water[pos];
        for(int i=pos;i<n-2;i++){
          sumf[i] = sumf[i+1];
          isfull[i] = isfull[i+1];
          wall[i+1] = wall[i+2];
          water[i] = water[i+1];
        }
        n--;
        isfull[pos] = false;
      } else {
        for(int i=pos+1;i<n;i++){
          if(wall[i].second < wall[i+1].second || !isfull[i]){
            sumf[i] += sumf[pos];
            break;
          }
        }
        sumf[pos] = 0;
      }
    }

    for(int i=0;i<n-1;i++){
      //debug(i);
      //debug(wall[i].first);
      //debug(wall[i+1].first);
      assert(water[i] - 1e-5 < min(wall[i].second, wall[i+1].second) * 30 * (wall[i+1].first - wall[i].first) );
    }

    curT = nextT;
  }

  for(int i=0;i<q;i++){
    printf("%.10lf\n", ans[i]);
  }

  return true;
}


int main(){
  int d;

  scanf("%d", &d);

  while(d--) solve();
  
  return 0;
}

