t = int(input())
buf = []
MOD = 10 ** 9 + 7
for _ in range(t):
n, a, b = map(int, input().split())
if n < a + b:
buf.append(0)
continue
if a < b:
a, b = b, a
ans1 = (n - a - b + 2) * (n - a - b + 1) ** 2 * (n + a - b) % MOD
ans2 = 2 * b * (n - b + 1) * (n - a - b + 2) * (n - a - b + 1) % MOD
buf.append((ans1 + ans2) % MOD)
print('\n'.join(map(str, buf)))
import os
import sys
import numpy as np
def solve(h, w, f):
hor = np.zeros_like(f, dtype=np.int64)
ver = np.zeros_like(f, dtype=np.int64)
MOD = 10 ** 9 + 7
def mod_pow(x, a, MOD):
ret = 1
cur = x
while a:
if a & 1:
ret = ret * cur % MOD
cur = cur * cur % MOD
a >>= 1
return ret
for i in range(h):
suc = 0
for j in range(w):
if f[i][j] == 1:
suc = 0
else:
suc += 1
hor[i][j] = suc
for j in range(w):
suc = 0
for i in range(h):
if f[i][j] == 1:
suc = 0
else:
suc += 1
ver[i][j] = suc
for i in range(h):
for j in range(w - 2, -1, -1):
if hor[i][j] == 0 or hor[i][j + 1] == 0:
continue
else:
hor[i][j] = hor[i][j + 1]
for j in range(w):
for i in range(h - 2, -1, -1):
if ver[i][j] == 0 or ver[i + 1][j] == 0:
continue
else:
ver[i][j] = ver[i + 1][j]
blank = h * w - f.sum()
tot = hor + ver - 1
ans = 0
for i in range(h):
for j in range(w):
if tot[i][j] == -1:
continue
ans = (ans + (mod_pow(2, tot[i][j], MOD) - 1) * mod_pow(2, blank - tot[i][j], MOD)) % MOD
return ans
if sys.argv[-1] == 'ONLINE_JUDGE':
from numba.pycc import CC
cc = CC('my_module')
cc.export('solve', '(i8,i8,i1[:,:],)')(solve)
cc.compile()
exit()
if os.name == 'posix':
# noinspection PyUnresolvedReferences
from my_module import solve
else:
from numba import njit
solve = njit('(i8,i8,i1[:,:],)', cache=True)(solve)
print('compiled', file=sys.stderr)
h, w = map(int, input().split())
field = np.array([['.#'.index(c) for c in input()] for _ in range(h)], dtype=np.int8)
ans = solve(h, w, field)
print(ans)
import os
import sys
import numpy as np
def solve(inp):
MOD = 10 ** 9 + 7
def mod_pow(x, a, MOD):
ret = 1
cur = x
while a:
if a & 1:
ret = ret * cur % MOD
cur = cur * cur % MOD
a >>= 1
return ret
INVERSE_CACHE = {-1: -1}
def inv(x):
if x not in INVERSE_CACHE:
INVERSE_CACHE[x] = mod_pow(x, MOD - 2, MOD)
return INVERSE_CACHE[x]
# [x^0, x^1, ...] の係数で多項式を表現
def poly_mul(p1, p2):
# 今のところ、p2は ax+b という形のみ
ret = np.zeros(p1.size + 1, np.int64)
ret[:p1.size] = p1 * p2[0] % MOD
ret[1:] += p1 * p2[1]
ret %= MOD
return ret
def poly_div(p1, p2):
# 今のところ、p2は ax+b という形のみ
ret = np.zeros(p1.size - 1, np.int64)
a = 0
iv = inv(p2[0])
for i in range(p1.size - 1):
ret[i] = a = (p1[i] - a * p2[1]) % MOD * iv % MOD
return ret
def poly_derivative(p):
ret = np.zeros(p.size - 1, np.int64)
for i in range(p.size - 1):
ret[i] = p[i + 1] * (i + 1) % MOD
return ret
def poly_integral(p):
ret = np.zeros(p.size + 1, np.int64)
for i in range(p.size):
ret[i + 1] = p[i] * inv(i + 1) % MOD
return ret
def poly_substitute(p, x):
ret = 0
y = 1
for i in range(p.size):
ret = (ret + p[i] * y) % MOD
y = y * x % MOD
return ret
n = inp[0]
lr = inp[1:]
slr = [(-1, 0, -1)]
for i in range(2 * n):
slr.append((lr[i], i & 1, i >> 1))
slr.sort()
lll = lr[0::2]
rrr = lr[1::2]
max_l = lll.max()
poly_x = np.array([0, 1], np.int64)
poly = np.ones(1, np.int64)
ans = 0
for i in range(2 * n):
s, f, j = slr[i]
t, g, k = slr[i + 1]
if t > max_l and s < t:
f = poly_integral(poly_mul(poly_derivative(poly), poly_x))
tmp = poly_substitute(f, t) - poly_substitute(f, s)
ans = (ans + tmp) % MOD
l = lll[k]
r = rrr[k]
if g == 0:
mul = np.array([-l, 1], np.int64)
poly = poly_mul(poly, mul) * inv(r - l) % MOD
else:
div = np.array([-l, 1], np.int64)
poly = poly_div(poly, div) * (r - l) % MOD
for i in range(2, n + 2):
ans = ans * i % MOD
for i in range(n):
l = lll[i]
r = rrr[i]
ans = ans * (r - l) % MOD
return ans
if sys.argv[-1] == 'ONLINE_JUDGE':
from numba.pycc import CC
cc = CC('my_module')
cc.export('solve', '(i8[:],)')(solve)
cc.compile()
exit()
if os.name == 'posix':
# noinspection PyUnresolvedReferences
from my_module import solve
else:
from numba import njit
solve = njit('(i8[:],)', cache=True)(solve)
print('compiled', file=sys.stderr)
inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print(ans)