Problem: Mr. Denjiro is a science teacher. Today he has just received a specially ordered water tank that will certainly be useful for his innovative experiments on water flow.

<image>
---
Figure 1: The water tank

The size of the tank is 100cm (Width) * 50cm (Height) * 30cm (Depth) (see Figure 1). For the experiments, he fits several partition boards inside of the tank parallel to the sideboards. The width of each board is equal to the depth of the tank, i.e. 30cm. The height of each board is less than that of the tank, i.e. 50 cm, and differs one another. The boards are so thin that he can neglect the thickness in the experiments.

<image>
---
Figure 2: The front view of the tank

The front view of the tank is shown in Figure 2.

There are several faucets above the tank and he turns them on at the beginning of his experiment. The tank is initially empty. Your mission is to write a computer program to simulate water flow in the tank.



Input

The input consists of multiple data sets. D is the number of the data sets.

D
DataSet1
DataSet2
...
DataSetD


The format of each data set (DataSetd , 1 <= d <= D) is as follows.

N
B1 H1
B2 H2
...
BN HN
M
F1 A1
F2 A2
...
FM AM
L
P1 T1
P2 T2
...
PL TL


Each line in the data set contains one or two integers.

N is the number of the boards he sets in the tank . Bi and Hi are the x-position (cm) and the height (cm) of the i-th board, where 1 <= i <= N .

Hi s differ from one another. You may assume the following.

> 0 < N < 10 ,
>  0 < B1 < B2 < ... < BN < 100 ,
>  0 < H1 < 50 , 0 < H2 < 50 , ..., 0 < HN < 50.

M is the number of the faucets above the tank . Fj and Aj are the x-position (cm) and the amount of water flow (cm3/second) of the j-th faucet , where 1 <= j <= M .

There is no faucet just above any boards . Namely, none of Fj is equal to Bi .

You may assume the following .

> 0 < M <10 ,
>  0 < F1 < F2 < ... < FM < 100 ,
>  0 < A1 < 100, 0 < A2 < 100, ... 0 < AM < 100.

L is the number of observation time and location. Pk is the x-position (cm) of the k-th observation point. Tk is the k-th observation time in seconds from the beginning.

None of Pk is equal to Bi .

You may assume the following .

> 0 < L < 10 ,
>  0 < P1 < 100, 0 < P2 < 100, ..., 0 < PL < 100 ,
>  0 < T1 < 1000000, 0 < T2 < 1000000, ... , 0 < TL < 1000000.

Output

For each data set, your program should output L lines each containing one real number which represents the height (cm) of the water level specified by the x-position Pk at the time Tk.

Each answer may not have an error greater than 0.001. As long as this condition is satisfied, you may output any number of digits after the decimal point.

After the water tank is filled to the brim, the water level at any Pk is equal to the height of the tank, that is, 50 cm.

Example

Input

2
5
15 40
35 20
50 45
70 30
80 10
3
20 3
60 2
65 2
6
40 4100
25 7500
10 18000
90 7000
25 15000
25 22000
5
15 40
35 20
50 45
70 30
80 10
2
60 4
75 1
3
60 6000
75 6000
85 6000


Output

0.666667
21.4286
36.6667
11.1111
40.0
50.0
30.0
13.3333
13.3333

Solution (in CPP):

Solution:
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#define REP(i,n) for(int i=0;i<(int)n;++i)
#ifdef __GNUC__
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T val){
  val = val - ((val >> 1) & 0x55555555);
  val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
  val = (val + (val >> 4)) & 0x0f0f0f0f;
  val += val >> 8;
  val += val >> 16;
  return (int)(val & 0x0000003f);
}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
ll getTen(int a){return (a<=0)?1:(getTen(a-1)*10);}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int N,M,L;
int bs[11],hs[11],fs[11],as[11],ps[11],ts[11];
double ress[11];
int main(){
  //ifstream cin("in.txt");
  int T;
  cin>>T;
  while(T--){
    cin>>N;
    for(int i=0;i<N;i++)cin>>bs[i]>>hs[i];
    cin>>M;
    for(int i=0;i<M;i++)cin>>fs[i]>>as[i];
    cin>>L;
    for(int i=0;i<L;i++)cin>>ps[i]>>ts[i];
    vector<pii> querys;
    for(int i=0;i<L;i++)querys.push_back(pii(ts[i],i));
    sort(querys.begin(),querys.end());
    vector<int> caps(N+2,0);
    vector<int> bPoss(N+2,0);
    vector<int> bHs(N+2,0);
    for(int i=1;i<N+1;i++)bPoss[i]=bs[i-1],bHs[i]=hs[i-1];
    bPoss[0]=0,bPoss[N+1]=100,bHs[0]=50,bHs[N+1]=50;
    int qPos=0;
    bool isOver=false;
    // queryをすべて処理するまで1sずつsimulationする
    for(int time=1;qPos<L;time++){
      //cout<<time<<endl;
      if(!isOver){
        // 蛇口の数だけ調べる
        for(int j=0;j<M;j++){
          int x=fs[j];
          int inQuan=as[j];
          if(isOver)break;
          // 今の場所から、inQuanがなくなるか、左右当量になるまでrecを繰り返す
          // その後、左右当量になっている場所をmergeし、inQuanが空になっていなければ、再びループして探索する
          while(inQuan&&!isOver){
            // 蛇口が備え付けられてある場所はどこか?
            int pos=lower_bound(bPoss.begin(),bPoss.end(),x)-bPoss.begin();
            bool isOverPos[11]={};
            // 現在の地点から探索をスタート
            while(1){
              const int width=(bPoss[pos]-bPoss[pos-1]);
              const int depth=30;
              const int maxCap=min(bHs[pos],bHs[pos-1])*width*depth;
              int &nowCap=caps[pos];
              if(inQuan==0)break;
              if(inQuan+nowCap<maxCap){
                nowCap+=inQuan;
                inQuan=0;
                break;
              }
              else{
                // もしあふれる場合
                inQuan-=(maxCap-nowCap);
                nowCap=maxCap;
                // すべて満杯
                if(bHs.size()==2){
                  isOver=true;
                  break;
                }
                isOverPos[pos]=true;
                // あふれたので、隣のノードを探索する
                int to=pos;
                // to lefft
                if(bHs[pos-1]<bHs[pos])to--;
                // to right
                else to++;
                // 移動先も満杯なら、breakする
                if(isOverPos[to]==isOverPos[pos])break;
                pos=to;
              }
            }
            // capsが隣合うところで同じところが1箇所以下存在するはずなので
            // その場所を見つけたらmergeする
            for(int i=1;i<(int)caps.size();i++){
              // 見つけたら、caps,bPoss,bHsをupdate
              if(isOverPos[i]&&isOverPos[i+1]&&min(bHs[i],bHs[i-1])==min(bHs[i],bHs[i+1])){
                caps[i+1]+=caps[i];
                //caps[i]+=caps[i+1];
                caps.erase(caps.begin()+i);
                bPoss.erase(bPoss.begin()+i);
                bHs.erase(bHs.begin()+i);
                break;
              }
            }
          }
        }
      }
      while(qPos<L&&time==querys[qPos].first){
        const int i=querys[qPos].second;
        int pos=lower_bound(bPoss.begin(),bPoss.end(),ps[i])-bPoss.begin();
        double quan=caps[pos];
        double width=bPoss[pos]-bPoss[pos-1];
        double depth=30;
        double height=quan/width/depth;
        ress[i]=height;
        qPos++;
      }
    }
    for(int i=0;i<L;i++){
      double height=ress[i];
      printf("%.10f\n",height);
    }
  }

  return 0;
}