Let's consider a rectangular table R consisting of N rows and M columns. Rows are enumerated from 1  to N from top to bottom. Columns are enumerated from 1 to M from left to right. Each element of R is a non-negative integer. R is called steady if the sum of elements in the ith row is not less then the sum of elements in the (i-1)th row for each i where 2 ≤ i ≤ N and the sum of elements in the Nth row is less than or equal to M. Your task is to find the number of different steady tables of size N x M modulo 1 000 000 000. 

-----Input-----
The first line of input contains a single integer T denoting number of test cases. First and the only line of each test case contains two space separated integers N and M denoting the number of rows and columns respectively.

-----Output-----
For each test case, print a single integer corresponding to the answer.

-----Constraints-----
- 1 ≤ T ≤ 10
- 1 ≤ N, M ≤ 2000

-----Subtasks-----
- Subtask 1 : 1 ≤ T ≤ 10 , 1 ≤ N,M ≤ 50 : ( 23 pts )
- Subtask 2 : 1 ≤ T ≤ 10 , 1 ≤ N,M ≤ 500 : ( 29 pts )
- Subtask 3 : 1 ≤ T ≤ 10 , 1 ≤ N,M ≤ 2000 : ( 48 pts )

-----Example-----
Input:
3
1 1
2 2
2 3
Output:
2
25
273

-----Explanation-----
Test case 1 : There are only 2 such grids possible 0 and 1.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = '# This is not my code, it\'s Snehasish Karmakar\'s.  Refer to http://www.codechef\xa0\xa0\xa0\xa0.com/viewsolution/7153774\n# for original version.\n# Submitting it to try and work out if it can be sped up.\n\ndef compute_nCr(n,r) :\n C[0][0]=1\n for i in range(1,n+1) :\n#       print "i",i\n  C[i][0]=1\n  for j in range(1,min(i,r)+1) :\n   if i!=j :\n    C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD\n   else :\n    C[i][j]=1\n  \n \ndef solve(n,m) :\n store=[C[m+i-1][i] for i in range(m+1)]\n \n for i in range(1,n+1) :\n  s=1\n  for j in range(1,m+1) :\n   s=(s+store[j])%MOD\n   store[j]=(s*C[m+j-1][j])%MOD\n  #   print "a[%d][%d]=%d"%(i,j,s)\n \n return s \n \nMOD=1000000000\nLIMIT=2000\n \nC=[[0] * (LIMIT + 1) for _ in range(2*LIMIT+1)]\ncompute_nCr(2*LIMIT,LIMIT)\nt=int(input())\n \nwhile t :\n n,m=list(map(int,input().split()))\n print(solve(n,m))\n t-=1'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: