#include <bits/stdc++.h>
constexpr int mod = 1e9 + 7;
int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int tt; cin >> tt;
	while (tt--) {
		int n, k; cin >> n >> k;
		vector<uint16_t> a(n);
		for (uint16_t &x : a) cin >> x;
		sort(a.begin(), a.end(), greater<uint16_t> ());
		int N = 1, M = 1;
		for (int i = k - 2; i >= 0 && a[i] == a[k - 1]; --i) ++N, ++M;
		for (int i = k; i < n && a[i] == a[k - 1]; ++i) ++N;
		auto qpow = [&](int a, int b) -> int {
			int res = 1;
			while (b) {
				if (b & 1) res = 1ll * res * a % mod;
				a = 1ll * a * a % mod, b >>= 1;
			}
			return res;
		};
		auto C = [&](int N, int M) -> int {
			int res = 1;
			for (int i = 0; i < M; ++i)
				res = 1ll * res * (N - i) % mod * qpow(i + 1, mod - 2) % mod;
			return res;
		};
		cout << C(N, M) << '\n';
	}
}