mod = 10**9+7 ### for bigger prime fact = [1,1] finv = [1,1] inv = [0,1] for i in range(2,4*10**5+5): fact.append((fact[-1]*i)%mod) inv.append((inv[mod%i]*(mod-mod//i))%mod) finv.append((finv[-1]*inv[-1])%mod) def nCr(n,r,mod): if r > n: return 0 else: return fact[n]*finv[r]*finv[n-r]%mod t = int(input()) for _ in range(t): h,w = map(int,input().split()) if h == 1 or w == 1: print(0) continue ans = 2*(h+w-3)*nCr(h+w-4,h-2,mod)%mod print(ans)