#include<bits/stdc++.h>	
#define int long long int
#define endl "\n"
#define mod 1000000007
#define inf 1e18     
using namespace std;
const int N = 1001;
const int mx = 2e5 + 5;
int fact[mx], invfact[mx], inv[mx];
//fact[] = n % mod;
//invfact[] = (1 / n!) % mod;
//inv[] = (1 / n) % mod
//cal_fact = Call in main function pre-comp
//nck = nCr
int powm(int x, int y){          
    int res = 1;
    x %= mod;
    while(y){
        if(y & 1) res *= x;
        x *= x;
        x %= mod;
        res %= mod;
        y /= 2;
    }
    return res;
}
int modinv(int num){              
   return powm(num, mod - 2);
}
void cal_fact(){                 
   fact[0] = 1;
    for(int i = 1; i < mx; i++){
        fact[i] = fact[i - 1] * i;
        fact[i] %= mod;
    }
    inv[1] = 1;
    for(int i = 2; i < mx; i++)
        inv[i] = (mod - (mod / i) * inv[mod % i]) % mod;
    invfact[mx - 1] = modinv(fact[mx - 1]);
    for(int i = mx - 2; i >= 0; i--){
        invfact[i] = invfact[i + 1] * (i + 1);
        invfact[i] %= mod; 
   }
}
int nck(int n, int k){
    if(n < k)
        return 0;
    int temp = 0;
    temp = fact[n];
    temp %= mod;
    temp *= invfact[k];
    temp %= mod;
    temp *= invfact[n - k];
    return temp % mod;
}
void solve() {
	int n, k;
	cin >> n >> k;
	vector<int> cnt(n + 1, 0);
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	sort(a.rbegin(), a.rend());
	int last = a[k - 1];
	int tot = 0;
	for(int i = 0; i < k; i++)
		tot += (a[i] == last);
	cout << nck(cnt[last], tot) << endl;
}

int32_t main() {	
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t;
	cin >> t;
	cal_fact();
	while(t--){
		solve();
	}
}