#include <bits/stdc++.h>

#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)

#define endl "\n"
#define ll long long int
#define push push_back
#define pop pop_back
#define make make_pair

using namespace std;
//Copied from GeeksForGeeks
// A modular inverse based solution to
// compute nCr % p
#include <bits/stdc++.h>
using namespace std;
 
/* Iterative Function to calculate (x^y)%p
in O(log y) */
unsigned long long power(unsigned long long x, 
                                  int y, int p)
{
    unsigned long long res = 1; // Initialize result
 
    x = x % p; // Update x if it is more than or
    // equal to p
 
    while (y > 0) 
    {
     
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x) % p;
 
        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
 
// Returns n^(-1) mod p
unsigned long long modInverse(unsigned long long n,  
                                            int p)
{
    return power(n, p - 2, p);
}
 
// Returns nCr % p using Fermat's little
// theorem.
unsigned long long nCrModPFermat(unsigned long long n,
                                 int r, int p)
{
    // If n<r, then nCr should return 0
    if (n < r)
        return 0;
    // Base case
    if (r == 0)
        return 1;
 
    // Fill factorial array so that we
    // can find all factorial of r, n
    // and n-r
    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;
}

int main()
{
    fastio;
    int t;
    cin >> t;
    while (t--)
    {
       ll p=1e9+7; 
       ll n,k;
       cin >> n >> k;
       ll a[n];
       for (ll i = 0; i < n; i++)
       {
           cin >> a[i];
       }
       sort(a,a+n,greater<int>());
       ll b[k];
       for (ll i = 0; i < k; i++)
       {
           b[i]=a[i];
       }
       ll track1=0;
       for (ll i = 0; i < k; i++)
       {
           if (b[i]==b[k-1]) track1++;
       }
       ll track2=0;
       for (ll i = 0; i < n; i++)
       {
           if (a[i]==b[k-1]) track2++;
       }
       cout << nCrModPFermat(track2,track1,p) << endl;
    }
    return 0;
}