//#pragma comment(linker, "/STACK:102400000,102400000")
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <limits>
#include <climits>
#include <cstdio>
#include <complex>
#include <numeric>
#include <cassert>
#include <bitset>
#include <chrono>
#include <random>
#include <unordered_set>
#define endl '\n'
#define mp(x,y) make_pair((x),(y))
#define PI pair<int,int>
#define PD pair<double,double>
#define PDI pair<double,int>
#define VI vector<int>
#define VLL vector<long long>
#define ll long long
#define ull unsigned long long
#define Fori(x) for(int i=0;i<(x);i++)
#define Forj(x) for(int j=0;j<(x);j++)
#define Fork(x) for(int k=0;k<(x);k++)
#define For1i(x) for(int i=1;i<=(x);i++)
#define For1j(x) for(int j=1;j<=(x);j++)
#define rep(x) for(auto &i:x)
#define NXT(x,y) (((x)+1)%(y))
#define NXT1(x,y) ((x)%(y)+1)
#define y1 asdfeawf
using namespace std;
//const int INF = 2147483647;
const int mod = 1000000007;
const int mod2 = 998244353;
const double eps = 1e-9;
const double pi = acos(-1.0);
bool is_sync_with_stdio = true;
inline int rint() { int x; if(is_sync_with_stdio) scanf("%d", &x); else cin>>x; return x; }
inline long long rll() { long long x; if(is_sync_with_stdio) scanf("%lld", &x); else cin>>x; return x; }
inline long long ri64() { long long x; scanf("%I64d", &x); return x; }
void rvi(vector<int> &a, int n) { for (int i = 0; i < n; i++) { a.push_back(rint()); } }
void rvll(vector<long long> &a, int n) { for (int i = 0; i < n; i++) { a.push_back(rll()); } }
void showvi(vector<int> &a) { for (int i = 0; i < a.size(); i++) { printf("%d%c", a[i], (i + 1 == a.size() ? '\n' : ' ')); } }
void showvll(vector<long long> &a) { for (int i = 0; i < a.size(); i++) { printf("%lld%c", a[i], (i + 1 == a.size() ? '\n' : ' ')); } }
void showviln(vector<int> &a) { for (int i = 0; i < a.size(); i++) { printf("%d%c", a[i], '\n'); } }
void showvllln(vector<long long> &a) { for (int i = 0; i < a.size(); i++) { printf("%lld%c", a[i], '\n'); } }
void showi(int x) { printf("%d", x); }
void cfinit() { ios::sync_with_stdio(false); cin.tie(0); is_sync_with_stdio = false;}
ll pw(ll a, ll b, ll c) {ll ans = 1; ll k = a % c; while(b>0){if(b % 2 == 1) ans = (ans * k) % c; b = b/2; k = (k * k) % c;} return ans;}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll mysqrt(ll n) { ll x = sqrt(1.0*n); while (x*x < n) x++; while (x*x > n) x--; return x; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {return (ull)rng() % B;}
ll myRand(ll l,ll r){ return myRand(r-l+1)+l;}
bool gangpener = 1;

/////////////////////线性求逆元

ll fac[2000022];
ll ifac[2000022];
ll inv[2000022];
void init_inverse() {
	inv[1] = 1;
	for (int i = 2; i < 2000022; i++)
		inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
}



void solve();
int main(){
	init_inverse();
	fac[0] = 1;
	for(int i=1;i<2000022;i++)
		fac[i] = fac[i-1]*i%mod;
	ifac[0] = inv[1];
	for(int i=1;i<2000022;i++)
		ifac[i] = ifac[i-1]*inv[i]%mod;
	cfinit(); int T = 1; if(gangpener) cin>>T; while(T--){solve();} return 0;
}




int n,k;
int a[1011];
void solve()
{
	cin>>n>>k;
	Fori(n) cin>>a[i];
	sort(a,a+n,greater<int>());
	int tar = a[k-1];
	int n1 = 0;
	int n2 = 0;
	for(int i=k-1;i>=0;i--) if(a[i]==tar) n1++;
	Fori(n) if(a[i]==tar) n2++;
	cout<<fac[n2]*ifac[n1]%mod*ifac[n2-n1]%mod<<endl;
}

