//------------------------ Un, Deux, Trois, Quatre, Cinq -----------------------//
#include<bits/stdc++.h>
using namespace std;

//Shorthands
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long 
#define ld long double
#define vll vector<ll>
#define vv vector<vll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ff first
#define ss second
#define tll tuple<ll,ll,ll>
#define vtll vector<tll> 
#define mt make_tuple
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define vect(a,n) vll a(n); rep(i,0,n) cin>>a[i];
#define all(a) a.begin(),a.end()
#define sortall(a) sort(a.begin(),a.end());
#define shuf(a) shuffle(a.begin(), a.end(), default_random_engine(0));

//Debug
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<endl;
#define pout(p) cout<<"("<<p.ff<<","<<p.ss<<")"<<endl;
#define tout(t) cout<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")"<<endl;
#define watch(x) cout<<(#x)<<"="<<x<<endl;
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n";
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n";
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n";
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n";

//Constants
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll mxN = 1e6;

//Input-Output File
void fileio(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
}
//-------------------------- Six, Sept, Huit, Neuf, Dix ------------------------//

const ll M = MOD ; 
ll fact[mxN];
ll ifact[mxN];
 
ll modExp(ll a, ll p) {
	a %= M;
	ll res=1;
	while(p > 0) {
		if(p & 1) res = res * a % M;
		a = a * a % M; 
		p >>= 1;
	}
	return res;
}
ll modInv(ll a) {
	return modExp(a,M-2) % M ;
}
void pre() {
	fact[0] = 1 ;
	for(ll i = 1; i< mxN; i++) 
		fact[i] = i * fact[i-1] % M ;
 
	ifact[mxN-1] = modInv(fact[mxN-1]) ; 
	
	for(ll i = mxN-1 ; i>0 ; i--) 
		ifact[i-1] = ifact[i] * i % M ;
}
 
ll nCr(ll n, ll r) {
	if (n < r || r < 0 || n < 0) return 0;
	ll res = fact[n] * ifact[r] % M * ifact[n-r] % M ;
	return res ;
}

void solve()
{ 
    ll n,k; cin>>n>>k;
    vect(a,n);
    sort(all(a),greater<ll>());

    ll m=0,r=0;
    rep(i,0,n)
    {
        if(i<k && a[i]==a[k-1]) r++;
        if(a[i]==a[k-1]) m++;
    }
    cout<<nCr(m,r)<<endl;
}

int main()
{
    fastio; fileio(); pre();
    ll tc; cin>>tc; while(tc--) 
    solve();
}
