#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct node{
    int left_pos,right_pos,left_height,right_height;
    double sum,flow;
};

void solve(){
    int n;
    cin >> n;
    vector<int> b(n+2),h(n+2); //???????????????
    b[0]=0;
    b[n+1]=100;
    h[0]=50;
    h[n+1]=50;
    rep(i,1,n+1) cin >> b[i] >> h[i];
    int m;
    cin >> m;
    vector<int> f(m),a(m); //???????????????
    rep(i,0,m) cin >> f[i] >> a[i];
    int l;
    cin >> l;
    vector<int> p(l),t(l); //???????????????
    vector<vector<int>> query(1000000);
    rep(i,0,l){
        cin >> p[i] >> t[i];
        query[t[i]].push_back(i);
    }

    list<node> intervals;
    rep(i,0,n+1){
        node n;
        n.left_pos=b[i];
        n.right_pos=b[i+1];
        n.left_height=h[i];
        n.right_height=h[i+1];
        n.sum=n.flow=0;
        rep(j,0,m){
            if(f[j]<n.left_pos or n.right_pos<f[j]) continue;
            n.flow+=a[j];
        }
        intervals.push_back(n);
    }
    vector<double> ans(l);
    rep(ct,1,1000000){
        for(auto &interval:intervals) interval.sum+=interval.flow;
        for(;;){
            bool update=false;
            for(auto it=intervals.begin();; ++it){
                auto left=it,right=it;
                ++right;
                if(min({left->left_height,left->right_height})==min({right->left_height,right->right_height}) and
                   left->sum+right->sum>=30*(right->right_pos-left->left_pos)*left->right_height){
                       node n=*left;
                       n.right_pos=right->right_pos;
                       n.right_height=right->right_height;
                       n.sum+=right->sum;
                       n.flow+=right->flow;
                       auto tmp=intervals.insert(left,n);
                       ++tmp;
                       tmp=intervals.erase(tmp);
                       intervals.erase(tmp);

                       update=true;
                       break;
                }
                if(right->right_height==50) break;
            }

            for(auto it=intervals.begin(); it!=intervals.end(); ++it){
                auto &interval=*it;
                double s=30*(interval.right_pos-interval.left_pos);
                if(interval.left_height<interval.right_height){
                    double h=interval.sum/s;
                    if(h>interval.left_height){
                        double d=h-interval.left_height;
                        interval.sum-=d*s;
                        auto left=it;
                        --left;
                        left->sum+=d*s;

                        update=true;
                    }
                }else{
                    double h=interval.sum/s;
                    if(h>interval.right_height){
                        double d=h-interval.right_height;
                        interval.sum-=d*s;
                        auto right=it;
                        ++right;
                        right->sum+=d*s;

                        update=true;
                    }
                }
            }
            if(!update or intervals.size()==1) break;
        }
        for(int i:query[ct]){
            for(auto interval:intervals){
                if(p[i]<interval.left_pos or interval.right_pos<p[i]) continue;
                ans[i]=min(50.,interval.sum/30/(interval.right_pos-interval.left_pos));
                break;
            }
        }
    }
    rep(i,0,l) cout << ans[i] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    int d;
    cin >> d;
    rep(i,0,d) solve();
    return 0;
}

Measured memory_bytes: 26624