---
category_name: easy
problem_code: STDYTAB
problem_name: 'Steady tables'
languages_supported:
- ADA
- ASM
- BASH
- BF
- C
- 'C99 strict'
- CAML
- CLOJ
- CLPS
- 'CPP 4.3.2'
- 'CPP 4.9.2'
- CPP14
- CS2
- D
- ERL
- FORT
- FS
- GO
- HASK
- ICK
- ICON
- JAVA
- JS
- 'LISP clisp'
- 'LISP sbcl'
- LUA
- NEM
- NICE
- NODEJS
- 'PAS fpc'
- 'PAS gpc'
- PERL
- PERL6
- PHP
- PIKE
- PRLG
- PYTH
- 'PYTH 3.4'
- RUBY
- SCALA
- 'SCM guile'
- 'SCM qobi'
- ST
- TCL
- TEXT
- WSPC
max_timelimit: '2'
source_sizelimit: '50000'
problem_author: pavel1996
problem_tester: null
date_added: 21-09-2014
tags:
- combinatorics
- dynamic
- easy
- june15
- pavel1996
editorial_url: 'http://discuss.codechef.com/problems/STDYTAB'
time:
view_start_date: 1434360600
submit_start_date: 1434360600
visible_start_date: 1434360600
end_date: 1735669800
current: 1493558190
layout: problem
---
All submissions for this problem are available.### Read problems statements in [Mandarin Chinese](http://www.codechef.com/download/translated/JUNE15/mandarin/STDYTAB.pdf) and [Russian](http://www.codechef.com/download/translated/JUNE15/russian/STDYTAB.pdf).
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
<pre>
<b>Input:</b>
3
1 1
2 2
2 3
<b>Output:</b>
2
25
273
</pre>### Explanation
Test case 1 : There are only 2 such grids possible 0 and 1.