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

const int Max = 1005;
LL Inv[Max+5], fact[Max+5] = {1};
const LL mod = 1e9 + 7;

LL qpow(LL x, LL y) {
    LL ans = 1;
    for( ; y; y/=2, x = x*x%mod)
        if(y % 2 == 1) ans = ans*x%mod;
    return ans;
}

LL C(int n, int m) {
    return fact[n] * Inv[m] % mod * Inv[n-m] % mod;
}

void init() {
    for(int i = 1; i <= Max; ++i)
        fact[i] = fact[i-1] * i % mod;
    Inv[Max] = qpow(fact[Max], mod-2);
    for(int i = Max-1; i >= 0; --i)
        Inv[i] = Inv[i+1]*(i+1)%mod;
}

int a[1005];



int main() {
    init();
    int T;
    cin >> T;
    while(T--) {
        int n, k;
        cin >> n >> k;
        for(int i = 0; i < n; ++i)
            cin >> a[i];
        sort(a, a+n);
        int c1 = 1, c2 = 1;
        while(n-k+c1<n && a[n-k+c1] == a[n-k]) ++c1;
        while(n-k-c2>=0 && a[n-k-c2] == a[n-k]) ++c2;
        cout << C(c1+c2-1, c1) << endl;
    }
    return 0;
}