#include<iostream>
#include<cstdio>

using namespace std;

const int M=1e9+7;

int T,n,a,b,ans;

int mo2(int x){
	return (x<0)?x+M:x;
}

int get_sum(int l,int r,int k,int t){
	int key1=l*k+t,key2=r*k+t;
	return 1ll*(key1+key2)*(r-l+1)/2%M;
}

int main(){
	scanf("%d",&T);
	while (T--){
		scanf("%d%d%d",&n,&a,&b);
		if (n<a+b){
			puts("0");
			continue;
		}
		ans=mo2((1ll*(n-b+1)*(a+b-1)-get_sum(0,a-1,-1,a-1)-get_sum(n-a-b+1,n-b,1,-(n-a-b+1)))%M);
		printf("%d\n",mo2((1ll*(n-a+1)*(n-a+1)%M*(n-b+1)%M*(n-b+1)-1ll*ans*ans)%M));
	}
	return 0;
}
    #include <bits/stdc++.h>
    typedef long long LL;
    #define SZ(X) ((int)(X).size())
    #define ALL(X) (X).begin(), (X).end()
    #define RALL(X) (X).rbegin(), (X).rend()
    #define REP(I, N) for (int I = 0; I < (N); ++I)
    #define REPP(I, A, B) for (int I = (A); I < (B); ++I)
    #define RI(X) scanf("%d", &(X))
    #define RII(X, Y) scanf("%d%d", &(X), &(Y))
    #define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
    #define DRI(X) int (X); scanf("%d", &X)
    #define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
    #define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
    #define DRVI(N, X) VI X(N); for (int ___I=0; ___I<N; ___I++) scanf("%d", &(X[___I]))  
    #define RS(X) scanf("%s", (X))
    #define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
    #define MP make_pair
    #define PB push_back
    #define MS0(X) memset((X), 0, sizeof((X)))
    #define MS1(X) memset((X), -1, sizeof((X)))
    #define LEN(X) strlen(X)
    #define PII pair<int,int>
    #define VI vector<int>
    #define VL vector<long long>
    #define VPII vector<pair<int,int> >
    #define PLL pair<long long,long long>
    #define VPLL vector<pair<long long,long long> >
    #define F first
    #define S second

    using namespace std;

    int main(){
        DRII(h,w);
        DRII(n,m);
        vector<VI> v(h, VI(w,0));
        vector<pair<PII,int>> b;
        REP(i,n){
            DRII(x,y);
            x--;y--;
            v[x][y]=1;
            b.PB({{x,y},0});
        }
        REP(i,m){
            DRII(x,y);
            x--;y--;
            v[x][y]=-1;
        }

        int it=0;
        VI rv(h*w,0);
        int res=0;
        while (it<SZ(b)){
            int rr;
            if (b[it].S==0) rr=15;
            else rr=(1<<(b[it].S-1));
            if (rr^(rr&rv[b[it].F.F*w+b[it].F.S])){
                if (rv[b[it].F.F*w+b[it].F.S]==0) res++;
                rv[b[it].F.F*w+b[it].F.S]|=rr;
            }
            else{
                it++;
                continue;
            }
            if (b[it].S==0 or b[it].S==1){
                int x=b[it].F.F;
                int y=b[it].F.S;
                if (x+1<h and v[x+1][y]!=-1){
                    b.PB({{x+1,y},1});
                }
            }
            if (b[it].S==0 or b[it].S==2){
                int x=b[it].F.F;
                int y=b[it].F.S;
                if (y+1<w and v[x][y+1]!=-1){
                    b.PB({{x,y+1},2});
                }
            }
            if (b[it].S==0 or b[it].S==3){
                int x=b[it].F.F;
                int y=b[it].F.S;
                if (x>0 and v[x-1][y]!=-1){
                    b.PB({{x-1,y},3});
                }
            }
            if (b[it].S==0 or b[it].S==4){
                int x=b[it].F.F;
                int y=b[it].F.S;
                if (y>0 and v[x][y-1]!=-1){
                    b.PB({{x,y-1},4});
                }
            }
            it++;
        }
        printf("%d\n",res);


    }
