#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
using ll      = long long;
int main() {
    ios_base::sync_with_stdio(false), cin.tie(0);
    int T = 1;
    ll N, A, B;
    for (cin >> T; T--;) {
        cin >> N >> A >> B;
        ll C = N - A + 1, D = N - B + 1, E = N - A - B;
        ll f   = E < 0 ? 0 : (E + 2) * (E + 1) / 2 % mod;
        ll ans = 4 * f * (C * D % mod - f) % mod;
        cout << (ans + mod) % mod << '\n';
    }
    return 0;
}
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll;
const int N=55;
int n,a[N],b[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
ll ans=2e18;
ll gcd(ll a,ll b){
	if(!b){
		return a;
	}
	return gcd(b,a%b);
}
bool check(ll x){
	for(int i=1;i<=n;i++){
		if(gcd(x,a[i])==1){
			return false;
		}
	}
	return true;
}
void dfs(int x,ll k){
	if(k>=ans){
		return;
	}
	if(check(k)){
		ans=k;
		return;
	}
	if(x>=15){
		return;
	}
	dfs(x+1,k*b[x]);
	dfs(x+1,k);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	dfs(0,1);
	printf("%lld\n",ans);
	return 0;
}