#include <stdio.h>
#include <algorithm>
#include <functional>
#define Max 1500
#define Res 1000000007

using namespace std;

int N, M, A, B;
int d[Max];
long long D[Max + 100][Max + 100];

void make_set() {
	int i, u;

	D[0][0] = 1;
	for (i = 0; i < Max; i++) for (u = 0; u < Max; u++) D[i + 1][u] += D[i][u], D[i + 1][u + 1] += D[i][u], D[i + 1][u] %= Res, D[i + 1][u + 1] %= Res;
}

void process() {
	int i;
	long long n;

	scanf("%d%d", &N, &M);
	for (i = 0; i < N; i++) scanf("%d", &d[i]);
	sort(d, d + N, greater<int>());

	for (i = A = 0; i < N; i++) if (d[i] == d[M - 1]) A++;
	for (i = B = 0; i < M; i++) if (d[i] == d[M - 1]) B++;

	printf("%lld\n", D[A][B]);
}

int main() {
	int T;

	make_set();

	scanf("%d", &T);
	while (T--) process();

	return 0;
}
