#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; ll factorial(int n,int M){ if(n<=1) return 1; return (factorial(n-1,M)*n)%M; } ll power(int k,int n,int M){ if(n==0) return 1; if(n==1) return (ll)k; ll ret = power(k,n/2,M); ret=(ret*ret)%M; if(n%2==1) ret=(ret*k)%M; return ret; } //nCm (mod p) p is prime number int C(int n,int m,int M){ if(m==0 || n==m) return 1; ll chi = factorial(n,M); ll mot = (factorial(m,M) * factorial(n-m,M))%M; mot = power((int)mot,M-2,M); ll ret = (chi*mot)%M; return (int)ret; } int P(int n,int m,int M){ if(m==0) return 1; ll chi = factorial(n,M); ll mot = factorial(n-m,M); mot = power((int)mot, M-2,M); ll ret = (chi*mot)%M; return (int)ret; } int H(int n,int m,int M){ return C(n+m-1,m,M); } int main(){ int t,n,k,ans; int mod = 1000000007; char S; scanf("%d",&t); for(int i=0;i