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

const int N = 1e3 + 20, MOD = 1e9 + 7;

int t, n, k, a[N];
int c[N][N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= i; j++) {
			if(j == 0 || j == i) c[i][j] = 1;
			else c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
			c[i][j] %= MOD;
		}
	}

	cin >> t;
	while(t--) {
		cin >> n >> k;
		for(int i = 0; i < n; i++) cin >> a[i];

		sort(a, a + n);
		int val = a[n - k], cnt = count(a, a + n, val);
		int taken = 0;
		for(int i = n - 1; i >= n - k; i--) {
			if(a[i] == val) taken++;
		}

		cout << c[cnt][taken] << "\n";
	}
}