#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum Type{
	IN,
	LEFT,
	RIGHT,
	DOUBLE,
};

enum Event{
	Water_full,
	Height_calc,
};

struct Info{
	void set(double arg_left_H,double arg_right_H,double arg_left_X,double arg_right_X,double arg_per_water,double arg_water_height){
		left_H = arg_left_H;
		right_H = arg_right_H;
		left_X = arg_left_X;
		right_X = arg_right_X;
		per_water = arg_per_water;
		water_height = arg_water_height;
	}

	double left_H,right_H,left_X,right_X,per_water,water_height;
	Type type;
};

struct Data{
	Data(double arg_time,double arg_LOC,int arg_id,Event arg_event){
		time = arg_time;
		LOC = arg_LOC;
		id = arg_id;
		event = arg_event;
	}
	bool operator<(const struct Data &arg) const{
		return time > arg.time; //時間の降順(PQ)
	}
	double time,LOC;
	int id;
	Event event;
};

Info info[11],next_info[11];
double in_water[11];

void func(){

	int N;
	scanf("%d",&N);

	for(int i = 0; i <= N; i++){
		info[i].per_water = 0.0;
		info[i].water_height = 0;
		info[i].type = IN;
	}

	double X,height;
	info[0].left_X = 0;
	info[0].left_H = 50.0;

	for(int i = 1; i <= N; i++){
		scanf("%lf %lf",&X,&height);
		info[i-1].right_X = X;
		info[i-1].right_H = height;
		info[i].left_X = X;
		info[i].left_H = height;
	}
	info[N].right_X = 100.0;
	info[N].right_H = 50.0;
	N++;

	int M;
	scanf("%d",&M);

	double water;
	for(int loop = 0; loop < M; loop++){
		scanf("%lf %lf",&X,&water);
		for(int i = 0; i < N; i++){
			if(X > info[i].left_X && X < info[i].right_X){
				info[i].per_water += water;
				break;
			}
		}
	}

	for(int i = 0; i < N; i++)in_water[i] = info[i].per_water;

	int L;
	scanf("%d",&L);

	priority_queue<Data> Q;
	double tmp_time;
	for(int loop = 0; loop < L; loop++){
		scanf("%lf %lf",&X,&tmp_time);
		Q.push(Data(tmp_time,X,loop,Height_calc));
	}

	//最初に満杯になる区間を計算する
	double min_time = DBL_MAX;
	int min_id;
	for(int i = 0; i < N; i++){
		tmp_time = (info[i].right_X-info[i].left_X)*min(info[i].left_H,info[i].right_H)*30.0/info[i].per_water;
		if(tmp_time < min_time){
			min_time = tmp_time;
			min_id = i;
		}
	}

	Q.push(Data(min_time,-1,min_id,Water_full));
	double pre_calc_height_time = 0; //水が満杯になるタイミングのみで計算する
	double add_water,add_height,pre_height,new_per_water;
	int id,count = 0,left_id,right_id,next_info_index;
	int merge_left,merge_right;

	double ans[10];

	while(!Q.empty()){

		if(Q.top().event == Height_calc){

			//どの区間の高さを求めればよいのか調べる
			for(int i = 0; i < N; i++){
				if(Q.top().LOC > info[i].left_X && Q.top().LOC < info[i].right_X){
					id = i;
					break;
				}
			}

			if(info[id].type == IN){ //水位が増える場合

				add_water = in_water[id]*(Q.top().time-pre_calc_height_time);
				add_height = add_water/((info[id].right_X-info[id].left_X)*30.0);

				ans[Q.top().id] = info[id].water_height+add_height;

			}else{ //水位に変化がない場合
				ans[Q.top().id] = info[id].water_height;
			}
			count++;
			if(count == L){
				for(int k = 0; k < L; k++){
					printf("%.10lf\n",ans[k]);
				}
				return;
			}

		}else{ //Q.top().event == Water_full

			//全区間の水の高さを計算
			for(int i = 0; i < N; i++){
				if(info[i].type != IN)continue; //流れ出る区間はSKIP
				add_water = in_water[i]*(Q.top().time-pre_calc_height_time);
				add_height = add_water/((info[i].right_X-info[i].left_X)*30.0);
				info[i].water_height += add_height;
			}
			pre_calc_height_time = Q.top().time;

			id = Q.top().id;
			merge_left = id;
			merge_right = id;
			//左または右と高さが等しくなれば、区間を統合する(★隣接する区間の高さが異なるようにする★)

			//左が満杯でかつ高さが等しい
			if(id > 0 && info[id-1].type != IN && fabs(info[id-1].water_height-info[id].water_height) < EPS){
				merge_left = id-1;
			}

			if(id+1 < N && info[id+1].type != IN && fabs(info[id+1].water_height-info[id].water_height) < EPS){
				merge_right = id+1;
			}

			new_per_water = 0;
			for(int i = merge_left; i <= merge_right; i++){
				new_per_water += info[i].per_water;
			}

			next_info_index = 0;
			//新しい区間集合を作成
			for(int i = 0; i < merge_left; i++){
				next_info[next_info_index++] = info[i];
			}
			next_info[next_info_index].type = DOUBLE; //★★かつて自分に流れ込んでいた水の行先を変更するため★★
			next_info[next_info_index++].set(info[merge_left].left_H,info[merge_right].right_H,info[merge_left].left_X,info[merge_right].right_X,
								new_per_water,info[merge_left].water_height);
			for(int i = merge_right+1; i < N; i++){
				next_info[next_info_index++] = info[i];
			}

			N = next_info_index;
			for(int i = 0; i < N; i++){
				info[i] = next_info[i];
			}

			for(int i = 0; i < N; i++)in_water[i] = 0;

			//水の流れ方の変化を計算する
			for(int i = 0; i < N; i++){
				if(info[i].water_height+EPS < min(info[i].left_H,info[i].right_H)){ //水位が左右の壁の低い方の高さより低い
					info[i].type = IN;
					in_water[i] += info[i].per_water;
					continue;
				}

				//水があふれる場合→水の流入場所を計算する
				id = i;
				left_id = id;

				//左側
				left_id = id;
				pre_height = info[id].water_height;
				while(left_id > 0 && info[left_id-1].water_height < pre_height && info[left_id-1].right_H <= pre_height+EPS){
					left_id--;
					pre_height = info[left_id].water_height;
					if(info[left_id].type == IN)break;
				}

				//右側
				right_id = id;
				pre_height = info[id].water_height;
				while(right_id+1 < N && info[right_id+1].water_height < pre_height && info[right_id+1].left_H <= pre_height+EPS){
					right_id++;
					pre_height = info[right_id].water_height;
					if(info[right_id].type == IN)break;
				}

				if(left_id == id){ //自分より左に、水が流れ込む場所がない

					if(right_id == id){ //右にも流れ込む場所がない→水槽自体が満杯になったということ
						info[i].type = DOUBLE; //仮に両側としておく
					}else{
						info[i].type = RIGHT;
						in_water[right_id] += info[i].per_water;
					}

				}else{ //自分より左に、水が流れ込む場所がある

					if(right_id == id){ //右には流れ込む場所がない
						info[i].type = LEFT;
						in_water[left_id] += info[i].per_water;
					}else{ //右にも流れ込む場所がある
						info[i].type = DOUBLE;
						in_water[left_id] += info[i].per_water/2;
						in_water[right_id] += info[i].per_water/2;
					}
				}
			}

			//次に、最初に満杯になる区間と時刻を計算
			min_time = DBL_MAX;
			for(int i = 0; i < N; i++){
				if(info[i].type != IN)continue;
				tmp_time = (info[i].right_X-info[i].left_X)*(min(info[i].left_H,info[i].right_H)-info[i].water_height)*30.0/in_water[i];
				if(tmp_time < min_time){
					min_time = tmp_time;
					min_id = i;
				}
			}

			Q.push(Data(Q.top().time+min_time,-1,min_id,Water_full));

		}
		Q.pop();
	}
}

int main(){

	int D;
	scanf("%d",&D);

	for(int loop = 0; loop < D; loop++){
		func();
	}

	return 0;
}



Measured memory_bytes: 3128