
/*                          AUTHOR
                            (_|_)
                             \_/
_______________________ÃMIT SÃRKER KISHÕR_______________________
----------------------------------------------------------------
_____DEPARTMENT OF CSE, CITY UNIVERSITY, DHAKA, BANGLADESH______
----------------------------------------------------------------
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ci std ::cin
#define co std ::cout
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d%d",&n,&m)
#define sl(n) scanf("%lld",&n)
#define sll(n,m) scanf("%lld%lld",&n,&m)
#define pd(n) printf("%d",n)
#define pdd(n,m) printf("%d%d",n,m)
#define pl(n) printf("%lld",n)
#define pll(n,m) printf("%lld%lld",n,m)
#define p_line printf("\n")
#define line cout<<endl
#define cas(n) printf("Case %d: ",n++)
#define task return
#define loop(x,n)  for(int x = 0 ; x < n ; x++)
#define constloop(x,a,n) for(int x = a ; x < n ; x++)
#define revloop(x,a,n)  for(int x = a ; x >= n ; x--)
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pi acos(-1)
const ll mx=100000;
const ll mod=1e9+7;
/*
ll P[mx+5],cnt=1;
bool nP[mx+5];
void sieve(void)
{
    P[0]=2;
    nP[0]=true;
    nP[1]=true;
    for(ll i=3 ; i<=mx ; i+=2)
    {
        if(nP[i]==true)
            continue;
        for(ll j=i+i ; j<=mx ; j+=i)
            nP[j]=true;
        P[cnt++]=i;
    }
}
*/
/*
ll bigMod(ll a, ll b)
{
    if(b<=0)
    {
        return 1;
    }
    ll value=bigMod(a,b/2);
    value=(value*value)%mod;
    if(b%2==1)
        value=(value*a)%mod;
    return value;
}
*/
/*
struct st
{
    int value;
    int pos; 
};
*/
/*
bool cmp(st n,st m)
{
    return n.a>m.a;
}
*/
/*
bool cmp(int n,int m)
{
    return m>n;
}
*/
ll bigmod(ll base,ll power)
{
	if(power<=0)
		return 1;
	ll value=bigmod(base,power/2);
	value=((value%mod)*value)%mod;
	if(power%2==1)
		value=((value%mod)*base)%mod;
	return value;
}
ll ncr(ll n,ll r)
{
	ll value1=1,value2=1;
	for(ll i=n-r+1 ; i<=n ; i++)
	{
		value1=((value1%mod)*i)%mod;
	}
	for(ll i=1 ; i<=r ; i++)
	{
		value2=((value2%mod)*i)%mod;
	}
	/*if(value2==0)
		return 1;*/
	value2=bigmod(value2,mod-2)%mod;
	return (value1*value2);
}
void solve()
{
    //Code here
    int t=1;
    ci>>t;
    while(t--)
    {
        ll n,k;
        ci>>n>>k;
        ll A[1000+5],frq[1000+5]={0};
        memset(frq,0,sizeof(frq));
        for(int i=1 ; i<=n ; i++)
        {
        	ci>>A[i];
        	frq[A[i]]++;
        }
        sort(A+1,A+n+1);
        reverse(A+1,A+n+1);
        ll a,b;
        a=frq[A[k]];
        ll temp=A[k];
        ll cnt=0;
        while(A[k]==temp && k>=0)
        {
        	k--;
        	cnt++;
        }
        b=a-cnt;
        ll ans=ncr(a,b)%mod;
        co<<ans;
        line;
    }
}
void I_O()
{
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    I_O();
    solve();
    //line;
    return 0;
}