#include <bits/stdc++.h>
using namespace std;
#define maxn 1005
#define mod 1000000007
typedef long long ll;
typedef pair<int, int> P;

int n, k;
int a[maxn];
bool cmp(int x, int y) { return x > y; }

ll f[maxn];
ll power(ll x, ll y)
{
    ll res = 1;
    while (y)
    {
        if (y & 1)
            res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}
ll inv(ll x) { return power(x, mod - 2); }
ll C(int x, int y) { return f[x] * inv(f[y] * f[x - y] % mod) % mod; }

int main()
{
    //freopen("tree.txt", "r", stdin);
    //freopen("1.out", "w", stdout);
    //std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    f[0] = 1;
    for (int i = 1; i < maxn; i++)
        f[i] = f[i - 1] * i % mod;
    int T;
    cin >> T;
    for (int kase = 1; kase <= T; kase++)
    {
        scanf("%d%d", &n, &k);
        for (int i = 1; i <= n; i++)
            scanf("%d", &a[i]);
        sort(a + 1, a + n + 1, cmp);
        int x = a[k];
        int aa = 0, b = 0;
        for (int i = 1; i <= n; i++)
        {
            if (a[i] == x)
            {
                aa++;
                if (i <= k)
                    b++;
            }
        }
        printf("%lld\n", C(aa, b));
    }
    return 0;
}
