#include<bits/stdc++.h>

using namespace std;

const int MOD = 1e9 + 7;
const int N = 1005;
int aa[N];

int bpow(int a, int b) {
    int res = 1;
    while(b) {
        if(b & 1) res = res * 1LL * a % MOD;
        a = a * 1LL * a % MOD;
        b >>= 1;
    }
    return res;
}

int fact(int n) {
    if(n <= 1) return 1;
    return fact(n-1) * 1LL * n % MOD;
}

void solveTest() {
    int n, k;
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> aa[i];
    sort(aa + 1, aa + n + 1);
    int total = count(aa + 1, aa + n + 1, aa[n-k+1]);
    int cnt = 0;
    for(int i = n; aa[i] != aa[n-k+1]; i--) cnt++;
    k -= cnt;
    cout << fact(total) * 1LL * (bpow(fact(k), MOD - 2) * 1LL * bpow(fact(total-k), MOD - 2) % MOD) % MOD << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int tt;
    cin >> tt;
    while(tt--)
        solveTest();

    return 0;
}
