

[1, 2] and [3].
[2, 3] and [1].
[1, 3] and [2].
The first line contains 'T', denoting the number of tests.
For each Test :
The only line contains two space-separated integers, 'N' and 'K', denoting the number of chocolates and bags, respectively.
For each test, print one integer, denoting the number of valid ways (modulo 10^9+7) to pack given 'N' chocolates into 'K' bags.
You are not required to print the expected output. It has already been taken care of. Just implement the function.
1 <= 'T' <= 10
1 <= 'K' <= 'N' <= 10^3
Time Limit: 1 sec
There will be two ways to pack this chocolate -
Merging both possibilities, Solution(N, K) = K * Solution(N-1, K) + Solution(N-1, K-1).
Repeat the same process for each chocolate, i.e., solve for i-th chocolate, assuming that you have a solution for (i-1) chocolates.
Algorithm:
We can see that when a recursion is called on pair (10, 7), pair (8, 6) is calculated multiple times, and there are many more pairs in the subtree.
A dp of size N*K is made to optimize this thing, which stores the result for each pair (N, K), and no pair is calculated multiple times.
Algorithm: