

You are given two integers N and K, you need to find the number of ways to divide N into k non-empty groups such that size of group[i] >= group[i - 1] for each valid i. Print it modulo 1e9 + 7.
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.
Output format:
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.
Note:
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.
1
4 2
2
There are 2 groups such that their sum is 4.
These are : [1, 3], [2, 2]
Note: You can’t have [3, 1] because it will have size of group[0] > group[1].
1
4 4
1
[1, 1, 1, 1] is the only way to divide 4 into 4 groups with the given condition.
What is the recurrence relation ?
O(N ^ K), Where N is the number of items and K is the number of groups .
Every time we decrement K by 1, our problem can be reduced into O(N) different subproblems.
So, Time complexity = N * N * N… N (K times) = O(N^K).
O(K), where K is the number of groups.
A recursion stack of size K will be used.