#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INT_MAX = 2147483646;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct Tank{
  int lx, rx;
  int lh, rh;
  double h;
  Tank() {}
};
struct Event{
  double t;
  int type;
  bool operator < (const Event& e) const {
    return t > e.t;
  }
  Event() {}
  Event(double t, int type) : t(t), type(type) {}
};
int main(){
  int D;
  cin >> D;
  while(D--){
    int N;
    cin >> N;
    vector<int> B(N + 2);
    vector<int> H(N + 2);
    REP(i, N) cin >> B[i + 1] >> H[i + 1];
    B[0] = 0,  B[N + 1] = 100;
    H[0] = INT_MAX/4, H[N + 1] = INT_MAX/4;
    int M;
    cin >> M;
    vector<int> F(M), A(M);
    REP(i, M) cin >> F[i] >> A[i];
    int L;
    cin >> L;
    vector<int> P(L), T(L);
    REP(i, L) cin >> P[i] >> T[i];

    vector<Tank> tank(N + 1);
    REP(i, N + 1){
      tank[i].lx = B[i];
      tank[i].rx = B[i + 1];
      tank[i].lh = H[i];
      tank[i].rh = H[i + 1];
      tank[i].h = 0;
    }
    priority_queue<Event> que;
    REP(i, L){
      que.push(Event(T[i], i));
    }
    que.push(Event(0, -1));
    vector<double> ans(L);
    while(!que.empty()){
      // queue process
      double t = que.top().t;
      /*
      printf("time = %lf\n", t);
      REP(i, tank.size()){
        printf("tank[%d]: lx = %d rx = %d lh = %d rh = %d h = %lf\n", i, tank[i].lx, tank[i].rx, tank[i].lh, tank[i].rh, tank[i].h);
      }
      */

      // if type >= 0 then output height;
      if(que.top().type >= 0){
        int idx = que.top().type;
        REP(i, tank.size()){
          if(tank[i].lx < P[idx] && P[idx] < tank[i].rx){
            ans[idx] = min(tank[i].h, 50.0);
            L--;
          }
        }
      }

      if(L == 0) break;
      que.pop();
      
      // push next event times
      vector<double> w_fall(tank.size(), 0);
      REP(i, M){
        REP(j, tank.size()) if(tank[j].lx < F[i] && F[i] < tank[j].rx) w_fall[j] += A[i];
      }
      REP(iter, tank.size()){
        REP(i, tank.size()) if(tank[i].h > 0) {
          if(tank[i].lh == tank[i].h && tank[i].rh == tank[i].h){
            w_fall[i - 1] += w_fall[i] / 2;
            w_fall[i + 1] += w_fall[i] / 2;
            w_fall[i] = 0;
          }else if(tank[i].lh == tank[i].h){
            w_fall[i - 1] += w_fall[i];
            w_fall[i] = 0;
          }else if(tank[i].rh == tank[i].h){
            w_fall[i + 1] += w_fall[i];
            w_fall[i] = 0;
          }
        }
      }
      // calc the time that some tanks are full.
      double min_time = que.top().t;
      REP(i, tank.size()) if(w_fall[i] > 0){
        double dt = 30.0 * (tank[i].rx - tank[i].lx) * (min(tank[i].lh, tank[i].rh) - tank[i].h) / w_fall[i];
       // printf("tank[%d] : fall = %lf dt = %lf\n", i, w_fall[i], dt);
        assert(dt > 0);
        min_time = min(min_time, t + dt);
      }
      if(min_time < que.top().t){
        que.push(Event(min_time, -1));
      }

      // update water heights
      double next_time = que.top().t;
      REP(i, tank.size()) if(w_fall[i] > 0){
        tank[i].h += w_fall[i] * (next_time - t) / (30.0 * (tank[i].rx - tank[i].lx));
        if(abs(tank[i].h - min(tank[i].lh, tank[i].rh)) < EPS) tank[i].h = min(tank[i].lh, tank[i].rh); // OK ??? 
      }

      /*
      printf("next_time = %lf\n", next_time);
      REP(i, tank.size()){
        printf("tank[%d]: lx = %d rx = %d lh = %d rh = %d h = %lf\n", i, tank[i].lx, tank[i].rx, tank[i].lh, tank[i].rh, tank[i].h);
      }
      */

      // merge segments
      vector<Tank> n_tank;
      REP(i, tank.size()){
        int j = i;
        while(j + 1 < tank.size() && tank[j].h == tank[j + 1].h && tank[j].h == tank[j].rh) j++;
        tank[i].rx = tank[j].rx;
        tank[i].rh = tank[j].rh;
        n_tank.push_back(tank[i]);
        i = j;
      }
      tank = n_tank;
    }
    REP(i, ans.size()) printf("%.16f\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 1236