#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;
ll dp[1005][1005];

ll ncr(ll n, ll r){
    if(n == r) return dp[n][r] = 1;
    else if(r == 1) return dp[n][r] = n;
    else if(dp[n][r]) return dp[n][r];
    else return dp[n][r] = ((ncr(n-1, r-1) % MOD) + (ncr(n-1, r) % MOD)) % MOD;
}

int main(){
    ll t;
    cin >> t;
    while(t--){
        ll n, k;
        cin >> n >> k;
        vector<ll> v(n);
        for(ll i = 0; i < n; i++) cin >> v[i];
        sort(v.rbegin(), v.rend());
        ll cnt = 0, r = 0, x = v[k-1];
        for(ll i = 0; i < n; i++){
            if(v[i] == x and i < k) r++;
            if(v[i] == x) cnt++;
        }
        cout << ncr(cnt, r) << endl;
    }
    return 0;
}
