#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int P = 1e9 + 7;
ll gcd(ll a, ll b){return b? gcd(b, a % b): a;}
ll quickpow(ll a, ll b){ll res = 1; while(b){if (b & 1) res = res * a % P; a = a * a % P; b >>= 1;} return res;}
// head

int t, n, k;
bool cmp(int a, int b) {return a > b;}

int C(int n, int m) {
	int ret = 1;
	for (int i = n - m + 1; i <= n; i++) ret *= i, ret %= P;
	for (int i = 1; i <= m; i++) ret *= quickpow(i, P - 2), ret %= P;
	return ret;
}

signed main(void){
	cin >> t;
	while (t--) {
		cin >> n >> k;
		vector<int> vt(n), cnt(n + 1, 0);
		for (int i = 0; i < n; i++) {
			cin >> vt[i];
			cnt[vt[i]]++;
		}
		sort(vt.begin(), vt.end(), cmp);
		int p = 0;
		for (int i = k - 1; i >= 0; i--) {
			if (vt[k - 1] == vt[i]) p++;
		}
		cout << C(cnt[vt[k - 1]], p) << endl;
	}
	return 0;
}
