#include <bits/stdc++.h>
using namespace std;

typedef long long big;
#define bigvec vector<big>
#define pbb pair<big, big>
#define pii pair<int, int>
#define fe first
#define se second
#define maxheap priority_queue
#define uset unordered_set
#define umap unordered_map
#define fr(i, s, e) for(big i = s; i < e; i++)
#define revfr(i, s, e) for(big i = s - 1; i >= e; i--)
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug(text) if(do_debug) {cout << text << endl;}
#define nl "\n"

const big mod = 1000000007;
const big infinity = 1000000000000000000;
bool do_debug = false;


vector<big> factorials(1001);
vector<big> mmo(1001);


big modular_multiplicative_inverse(big n, big m) {

	big retval = 1;
	big M = m - 2;

	while(M > 0) {

		if(M & 1) {

			retval = ((retval % m) * (n % m)) % m;
		}

		M = M >> 1;
		n = ((n % m) * (n % m)) % m;
	}

	return retval % m;
}


big nCr(big n, big r) {

	if(n < r) {

		return 0;
	}

	if (n == r) {

		return 1;
	}

	if(r == 0) {

		return 1;
	}

	return (((factorials[n] * mmo[r]) % mod) * mmo[n - r]) % mod;
}


void precompute() {

	factorials[0] = 1;
	factorials[1] = 1;
	mmo[0] = 1;
	mmo[1] = 1;

	for(int i = 2; i <= 1000; i++) {

		factorials[i] = (factorials[i - 1] * i) % mod;
		mmo[i] = modular_multiplicative_inverse(factorials[i], mod);
	}
}


void solve() {

	int n, k;
	cin >> n >> k;

	vector<int> v(n);
	vector<int> count(n + 1, 0);

	fr(i, 0, n) {

		cin >> v[i];
		count[v[i]]++;
	}

	sort(v.begin(), v.end());

	int repeated = v[n - k];
	int repcount = count[repeated];
	int repneeded = k - (n - (upper_bound(v.begin(), v.end(), repeated) - v.begin()));
	// we need repcount C repneeded;
	// cout << repcount << ", " << repneeded << endl;
	big ans = nCr(repcount, repneeded);
	cout << ans << nl;
}


int main() {
	
	speed;
	precompute();

	int q = 1;
	cin >> q;

	while(q-- > 0) {

		solve();
	}

	return 0;
}