Sherlock and Permutations
Difficulty: Hard

Watson asks Sherlock:  
Given a string _S_ of _N_ `0's` and _M_ `1's`, how many unique permutations of this string start with `1`?   

Help Sherlock by printing the answer modulo (_10<sup>9</sup>+7_).   

**Input Format**   
First line contains _T_, the number of test cases.  
Each test case consists of _N_ and _M_ separated by a space.

**Output Format**   
For each test case, print the answer modulo (_10<sup>9</sup>+7_).

**Constraints**  
1 &le; T &le; 200  
1 &le; N,M &le; 1000  

**Sample Input**   

	2
	1 1
	2 3
    
**Sample Output**      
	
    1
    6

**Explanation**  
Test1: Out of all unique permutations ie. `01` and `10`, only second permutation satisfies. Hence, output is 1.  
Test2: Out of all unique permutations ie. `00111 01011 01101 01110 10011 10101 10110 11001 11010 11100`, only `10011 10101 10110 11001 11010 11100` satisfy. Hence, output is 6.

Input Format:

Output Format:

Sample Input:

Sample Output:

Python 3 starter code:
#
# Complete the 'solve' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
#  1. INTEGER n
#  2. INTEGER m
#

def solve(n, m):
    # Write your code here




Reference solution (C++):
###C++  
```cpp  
//Language: C++ 
//Author: darkshadows(Lalit Kundu)
    
#include<bits/stdc++.h>
#define assn(n,a,b) assert(n<=b && n>=a)
using namespace std;
typedef long long LL;
#define MOD 1000000007
#define MAX 1000033
LL mpow(LL a, LL n)
{
    LL ret=1;
    LL b=a;
    while(n)
    {
        if(n&1)ret=(ret*b)%MOD;
        b=(b*b)%MOD;
        n>>=1;
    }
    return (LL)ret;
}
LL fac[MAX],inv[MAX];
void precalc()
{
    LL i;
    fac[0]=1;
    inv[0]=1;
    fac[1]=1;
    inv[1]=1;
    for(i=2; i<MAX; i++)
    {
        fac[i]=(i*fac[i-1])%MOD;
        inv[i]=mpow(fac[i],MOD-2);
    }
}
LL choose(LL n,LL r)
{
    if(n<r)return 0ll;
    LL ret1=(inv[r]*inv[n-r])%MOD;
    LL ret=(ret1*fac[n])%MOD;
    return ret;
}
int main()
{
    precalc();
    int t;
    cin >> t;
    assn(t,1,200);
    while(t--)
    {
        LL n,m,t=1ll,ans=1ll;
        cin >> m >> n;
        assn(n,1,1000);
        assn(m,1,1000);
        n--;
        m+=n;
        cout << choose(m,n) << endl;
    }
    return 0;
}
```