#include <bits/stdc++.h>
using namespace std;
 
#define S second
#define F first
#define LL long long
 
const int N = 5e5+10;

LL LINF = 100000000000000000;
LL INF = 1000000000;
LL MOD = 1e9+7;

LL a[N];
int freq[N];
int freq2[N];
LL fac[N];

LL mult(LL a,LL b){
    return (a*b)%MOD;
}

LL fastpow(LL n,LL k){

    LL ret = 1;
    while(k){

        if(k&1)ret = mult(ret,n);
        k /= 2;
        n = mult(n,n);
    }
    return ret;
}

LL divide(LL a,LL b){
    return mult(a,fastpow(b,MOD-2));
}

LL C(LL n,LL k){

    return divide(fac[n],mult(fac[n-k],fac[k]));
}

int main(){

    //freopen("out.txt","w",stdout);

    fac[0] = 1;
    for(int i=1;i<=2000;i++)
        fac[i] = mult(fac[i-1],i);

    int t;
    scanf("%d",&t);

    while(t--){
        
        memset(freq,0,sizeof(freq));
        memset(freq2,0,sizeof(freq2));

        int n,k;
        scanf("%d%d",&n,&k);

        for(int i=1;i<=n;i++)
            scanf("%lld",&a[i]),freq2[a[i]]++;

        sort(a+1,a+n+1);
        for(int i=n-k+1;i<=n;i++)
            freq[a[i]]++;

        LL ans = 1;
        for(int i=1;i<=1000;i++)
            ans = mult(ans,C(freq2[i],freq[i]));

        printf("%lld\n",ans);
    }

}