#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define TEST int t; cin>>t; while(t--)
#define pb push_back
#define mii map <int, int>
#define umii unordered_map <int,int>
#define pii pair <int, int>
#define vi vector <int>
#define ff first
#define ss second
#define vpii vector <pair <int, int> >
#define vvi vector <vector <int> >
#define vb vector <bool>
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(x); {cout<<#x<<"="<<x<<", ";}
#define in(x); { for (auto &to : x) cin>>to;}
#define out(x); { for (auto &to : x) cout<<to<<" ";cout<<'\n'; }
#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007
//----------------------------------SEIVE---------------------------------------------//
// vector<int>prime;
// bitset<1000030>vis;

// void seive()
// {
//   vis.set();
//   vis[0] = false;
//   vis[1] = false;
//   vis[2] = true;
//   prime.pb(2);
//   for (int i = 3; i <= 1000030; i += 2)
//   {
//     if (vis[i] == 1)
//     {
//       prime.pb(i);
//       for (int j = i * i; j <= 1000030; j += i)
//       {
//         vis[j] = 0;
//       }
//     }
//   }
// }
//----------------------------------SEIVE---------------------------------------------//
//--------------------------------CHECKPRIME------------------------------------------//
bool isPrime(int n)
{
  if (n < 2) return false;
  if (n < 4) return true;
  if (!(n & 1))   return false;
  if (n % 3 == 0) return false;

  int lim = sqrt(n);
  for (int i = 5; i <= lim; i += 6)
    if (n % i == 0 || n % (i + 2) == 0)
      return false;

  return true;
}
//--------------------------------CHECKPRIME------------------------------------------//
//-------------------------------PRIME FACTORS----------------------------------------//
map<int, int> primeFact(int n) {
  map<int, int> mp;
  while (n % 2 == 0) {
    mp[2]++;
    n = n / 2;
  }
  for (int i = 3; i <= sqrt(n); i += 2) {
    while (n % i == 0) {
      mp[i]++;
      n = n / i;
    }
  }
  if (n > 2) {
    mp[n]++;
  }
  return mp;
}
//-------------------------------PRIME FACTORS----------------------------------------//

int binomialCoeff(int n, int k)
{
  int C[n + 1][k + 1];
  int i, j;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= min(i, k); j++) {
      if (j == 0 || j == i)
        C[i][j] = 1;
      else
        C[i][j] = (C[i - 1][j - 1] % (mod) + C[i - 1][j] % (mod)) % (mod);
    }
  }

  return C[n][k];
}

void solve() {

  int n, k;
  cin >> n >> k;
  int a[n];
  map<int, int, greater<int>>m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  int cnt = 0;
  for (auto p : m) {
    if (p.ss >= k) {
      cout << cnt + binomialCoeff((int)p.ss, k) << endl;
      return;
    }
    else {

      //m.erase(p.ff);
      k -= p.ss;
    }
    //if (k == 0)break;
  }
  //cout << cnt << endl;


}
signed main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false); cin.tie(0);
  //seive();
  TEST
  solve();
  //for graph see start vertex is 1 or 0(mistake done many times).
  // so for applying dfs iter from 1 to n(when root is 1)
}