import sys input = sys.stdin.buffer.readline MOD = 10 ** 9 + 7 MAX = 4 * 10 ** 5 + 10 # https://tjkendev.github.io/procon-library/python/math/factorial.html から拝借しています。 fact = [1] * (MAX + 1) rfact = [1] * (MAX + 1) r = 1 for i in range(1, MAX + 1): fact[i] = r = r * i % MOD rfact[MAX] = r = pow(fact[MAX], MOD - 2, MOD) for i in range(MAX, 0, -1): rfact[i - 1] = r = r * i % MOD def comb(n, k, error=0): if not 0 <= k <= n: return error return fact[n] * rfact[k] * rfact[n - k] % MOD def solve(H, W): return 2 * comb(H + W - 4, H - 2) * (H + W - 3) % MOD T = int(input()) for _ in range(T): print(solve(*map(int, input().split())))