#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <stdio.h>
#include <cmath>
using namespace std;

typedef pair<int, int>II;
typedef pair<double, double>DD;
class Tank{
    public:
    II left;
    II right;
    double h;
};
class Scene{
    public:
    vector<Tank>Tanks;
    vector<II>Mizu;
    vector<DD>Water;
    void init(){
        int N;
        cin>>N;
        vector<II>vec;
        vec.push_back(II(-114514,51));
        vec.push_back(II(0,50));
        for(int i=0;i<N;i++){
            int p, h;
            cin>>p>>h;
            vec.push_back(II(p, h));
        }
        vec.push_back(II(100, 50));
        vec.push_back(II(114514, 51));
        Tanks.resize(vec.size()-1);
        for(int i=0;i+1<vec.size();i++){
            Tanks[i].left = vec[i];
            Tanks[i].right = vec[i+1];
            Tanks[i].h = 0.0;
            if(i==0 || (i+2==vec.size()))Tanks[i].h=-1000000000.0;
        }
        int M;
        cin>>M;
        for(int i=0;i<M;i++){
            int p, a;
            cin>>p>>a;
            Mizu.push_back(II(p, a));
        }
    }
    double simulate(int p, int t){
        for(int i=0;i<Mizu.size();i++){
            Water.push_back(DD(Mizu[i].first, t * Mizu[i].second/30.0));
        }
        for(int i=0;i<Water.size();i++){
            double pos = Water[i].first;
            double amo = Water[i].second;
            for(int j=0;j+1<Tanks.size();j++){
                if(abs(Tanks[j].h-Tanks[j+1].h)<1e-8 && 
                    abs(Tanks[j].h-Tanks[j].right.second)<1e-8){
                    Tanks[j+1].left=Tanks[j].left;
                    Tanks.erase(Tanks.begin()+j);
                    j--;
                }
            }
            for(int j=0;j<Tanks.size();j++){
                II L = Tanks[j].left, R = Tanks[j].right;
                if(L.first <= pos && pos <= R.first){
                    double w = R.first - L.first;
                    Tanks[j].h += amo/w;
                    if(abs(L.second-R.second)<1e-8){
                        if(Tanks[j].h > L.second){
                            double amari = (Tanks[j].h - L.second)*w;
                            Tanks[j].h = L.second;
                            Water.push_back(DD(L.first - 0.5, amari*0.5));
                            Water.push_back(DD(R.first + 0.5, amari*0.5));
                        }
                    }
                    else if(L.second>R.second){
                        if(Tanks[j].h > R.second){
                            double amari = (Tanks[j].h - R.second)*w;
                            Tanks[j].h = R.second;
                            Water.push_back(DD(R.first + 0.5, amari));
                        }
                    }
                    else{
                        if(Tanks[j].h > L.second){
                            double amari = (Tanks[j].h - L.second)*w;
                            Tanks[j].h = L.second;
                            Water.push_back(DD(L.first - 0.5, amari));
                        }
                    }
                    break;
                }
            }
        }
        for(int i=0;i<Tanks.size();i++){
            II L = Tanks[i].left;
            II R = Tanks[i].right;
            if(L.first <= p && p <= R.first){
                return Tanks[i].h;
            }
        }
        return -1.0;
    }
};

int main(){
    int D;
    cin>>D;
    for(int d=0;d<D;d++){
        Scene scene;
        scene.init();
        int L;
        cin>>L;
        for(int i=0;i<L;i++){
            int p, t;
            cin>>p>>t;
            Scene s = scene;
            printf("%.9f\n", s.simulate(p, t));
        }
    }
    return 0;
}


Measured memory_bytes: 3172