#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n, k;
cin >> n >> k;
vector<int> A(n,0);
unordered_map<int, int> mp;
for(int i=0;i<n;i++)
{
cin>>A[i];
mp[A[i]]++;
}
long long ans = 1;
sort(A.begin(),A.end());
vector<int> cost;
for (int i = 0; i < k; i++)
{
cost.push_back(A[i]);
}
int mx = *max_element(cost.begin(),cost.end());
int i = 0;
for (i = 0; i < k; i++)
{
if (A[i] == mx)
{
break;
}
}
while (i < k)
{
ans = ans * mp[mx];
mp[mx]--;
i++;
}
cout << ans << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKQp7CiAgICBpbnQgdDsKICAgIGNpbiA+PiB0OwogICAgd2hpbGUgKHQtLSkKICAgIHsKICAgICAgICBpbnQgbiwgazsKICAgICAgICBjaW4gPj4gbiA+PiBrOwogICAgICAgIHZlY3RvcjxpbnQ+IEEobiwwKTsKICAgICAgICB1bm9yZGVyZWRfbWFwPGludCwgaW50PiBtcDsKICAgICAgICBmb3IoaW50IGk9MDtpPG47aSsrKQogICAgICAgIHsKICAgICAgICAgICAgY2luPj5BW2ldOwogICAgICAgICAgICBtcFtBW2ldXSsrOwogICAgICAgIH0KICAgICAgICBsb25nIGxvbmcgIGFucyA9IDE7CiAgICAgICAgc29ydChBLmJlZ2luKCksQS5lbmQoKSk7CiAgICAgICAgdmVjdG9yPGludD4gY29zdDsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGs7IGkrKykKICAgICAgICB7CiAgICAgICAgICAgIGNvc3QucHVzaF9iYWNrKEFbaV0pOwogICAgICAgIH0KICAgICAgICBpbnQgbXggPSAqbWF4X2VsZW1lbnQoY29zdC5iZWdpbigpLGNvc3QuZW5kKCkpOwogICAgICAgIGludCBpID0gMDsKICAgICAgICBmb3IgKGkgPSAwOyBpIDwgazsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgaWYgKEFbaV0gPT0gbXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIHdoaWxlIChpIDwgaykKICAgICAgICB7CiAgICAgICAgICAgIGFucyA9IGFucyAqIG1wW214XTsKICAgICAgICAgICAgbXBbbXhdLS07CiAgICAgICAgICAgIGkrKzsKICAgICAgICB9CiAgICAgICAgY291dCA8PCBhbnMgPDwgZW5kbDsKICAgIH0KCiAgICByZXR1cm4gMDsKfQ==