

The first line contains an integer 'T' which denotes the number of test cases or queries to be run. Then, the T test cases follow.
The first line of every test case contains 2 space separated integers N and K.
For each test case, print the required number of ways modulo 1e9 + 7.
The output for each test case is printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function. DON'T forget to print modulo 1e9 + 7.
1 <= T <= 10
1 <= N <= 1000
1 <= K <= N
Where T is the number of test cases, N is the total number of items and K is the number of groups.
We are solving this problem by solving its subproblems and then combining the solutions of those subproblems. If we analyze carefully, we will see that we are solving the same subproblems multiple times. Thus, this problem exhibits overlapping subproblems. Thus, in this approach, we will eliminate the need for solving the same subproblems again and again.
The below figure shows some of the recursive calls made for the given problem.
With the initial call incrementalPartitioningHelper(16, 4, 5).
We can see that we are solving the problem incrementalPartitioningHelper(5, 1, 3) multiple times from 2 different recursive calls.
That’s why we are storing the solved subproblems in a lookup table so that we don’t have to solve them again. Whenever a call is made to the solved subproblem, we will directly return the answer of that subproblem stored in the lookup table.
Consider the following example: