#pragma GCC optimize ("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define FORD(i, a, b) for (int i=(a); i>(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19, mod = 1000000007;

template <class T1, class T2> inline void addMod(T1& a, T2 b)	{   a = (a + b) % mod;  }
template <class T1, class T2> inline void multMod(T1& a, T2 b)	{   a = a * b % mod;    }

long long sum(long long a, long long b)
{	return (a+b) * (b-a+1) / 2 % mod;	}

void solve()
{	
	long long n, a, b;
	scanf ("%lld%lld%lld", &n, &a, &b);
	if (a > b)
		swap(a, b);
		
	long long all = kw(n-a+1) % mod;
	multMod(all, kw(n-b+1) % mod);
	
	long long x = n+1-min(a+b-1, n);
	long long y = n+1-(b+1);
	long long bad = sum(x, y);
	multMod(bad, 2);
	addMod(bad, (n-b+1) * (b-a+1));
	multMod(bad, bad);
	multMod(bad, mod-1);
	long long res = all;
	addMod(res, bad);
	printf("%lld\n", res);
}
 
int main()
{
	int t = 1;
	scanf ("%d", &t);
	FOR(tid, 1, t+1)
	{
		//printf("Case #%d: ", tid);
		solve();
	}
	return 0;
}



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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  a%=10;
  if(a==0||a==1||a==5||a==6){
    cout<<a<<'\n';
    return 0;
  }else if(a==4||a==9){
    if(b%2==0){
      a=a*a%10;
    }
    cout<<a<<'\n';
    return 0;
  }else{
    b%=4;
    int t=b;
    b=1;
    for(int i=0;i<32;i++){
      if(c>>i&1)b=b*t%4;
      t=t*t%4;
    }
    b+=4;
    int ret=1;
    for(int i=0;i<b;i++)ret=ret*a%10;
    cout<<ret<<'\n';
    return 0;
  }
}