// What you say doesn't remain forever.

#include "bits/stdc++.h"

using namespace std;

#define int long long


constexpr int mod = 1e9 + 7;

struct M {
    unsigned v;
    M(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    M& operator+=(M r) { if ((v += r.v) >= mod) v -= mod; return *this; }
    M& operator-=(M r) { if ((v += mod - r.v) >= mod) v -= mod; return *this; }
    M& operator*=(M r) { v = (uint64_t)v * r.v % mod; return *this; }
};

uint32_t add(M a, M b) { return (a += b).v; }
uint32_t mul(M a, M b) { return (a *= b).v; }
uint32_t sub(M a, M b) { return (a -= b).v; }

uint32_t po(M x, int n) {
    M res(1);
    while (n > 0) {
        res *= (n & 1 ? x : 1);
        x *= x; n /= 2;
    }
    return res.v;
}



const int N = 1005;
int a[N];
constexpr int mm = 3 * N;
int fact[mm], invFact[mm];

void pre() {
    fact[0] = invFact[0] = invFact[1] = 1;

    for (int i = 1; i < mm; i++) {
        fact[i] = mul(fact[i - 1], i);
    }

    for (int i = 2; i < mm; i++) {
        invFact[i] = mul((mod - mod / i), invFact[mod % i]);
    }

    for (int i = 1; i < mm; i++) {
        invFact[i] = mul(invFact[i - 1], invFact[i]);
    }
}
int ncr(int n, int r) {
    assert(n >= 0 and r >= 0); if (n < r) return 0;
    return mul(mul(fact[n], invFact[r]), invFact[n - r]);
}


void solve() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n, greater<int>());
    if (a[1] == a[k]) {
        int x = count(a + 1, a + 1 + n, a[k]);
        assert(x >= k);
        cout << ncr(x, k) << '\n';
    }
    else {
        int t = 0;
        for (int i = 1; i <= n; ++i) {
            if (a[i] == a[k]) break;
            ++t;
        }
        int x = count(a + 1, a + 1 + n, a[k]);
        int ans = ncr(x, k - t);
        cout << ans << '\n';
    }
}

// #define single_test

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    pre();
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}