#include <bits/stdc++.h>
#define int long long
using namespace std;
 
 
unsigned long long power(unsigned long long x, 
                                  int y, int p)
{
    unsigned long long res = 1; 
    x = x % p; 
    while (y > 0) 
    {
     
        if (y & 1)
            res = (res * x) % p;
 
        y = y >> 1; 
        x = (x * x) % p;
    }
    return res;
}
 

unsigned long long modInverse(unsigned long long n,  
                                            int p)
{
    return power(n, p - 2, p);
}
 

unsigned long long nCrModPFermat(unsigned long long n,
                                 int r, int p)
{
    if (n < r)
        return 0;
    if (r == 0)
        return 1;
    unsigned long long fac[n + 1];
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = (fac[i - 1] * i) % p;
 
    return (fac[n] * modInverse(fac[r], p) % p
            * modInverse(fac[n - r], p) % p)
           % p;
} 
 
int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,k;
        cin>>n>>k;
        vector <int> v;
        for(int i=0;i<n;i++){
            int x;
            cin>>x;
            v.push_back(x);
        }
        sort(v.begin(),v.end());
        int in=0,count=0;
        for(int i=0;i<n;i++)
        {
            if(v[i]==v[n-k]) count++;
        }
        for(int i=(n-k);i<n;i++)
        {
            if(v[i]==v[n-k]) in++;
            else break;
        }
        int ans;
        int p = pow(10,9);
        p+=7;
        ans = nCrModPFermat(count, in, p);
        cout<<ans<<endl;
    }   
    
    return 0;
}