#include<bits/stdc++.h>
using namespace std;
#define l(a) int((a).size())
#define ll long long
#define f(i,n) for(i=0;i<n;i++)
#define vii vector<pair<int,int> v
#define vll vector<pair<long long,long long>v
#define mod 998244353
#define pb push_back
#define  fi first
#define se  second 
const int mx=100007;
vector<int>v;
int a[10];
long long power(long long a, long long b)
{
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    
    return res;
}
 
int modInverse(int a, int prime) 
{ 
    a = a % prime; 
    for (int x=1; x<prime; x++) 
       if ((a*x) % prime == 1) 
          return x; 
       
    return -1; 
}
 
int gcd(int a, int b)
{
    if (b == 0)
        return a;
        
    return gcd(b, a % b); 
     
}
 
void SieveOfEratosthenes(int n,vector<int> &v)
{
    bool prime[n+1];
    memset(prime,true,sizeof(prime));
    for(int i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(int j=i*i;j<=n;j+=i)
                prime[j]=false;
        }
    }  
    for(int i=2;i<=n;i++)
    {
       if(prime[i])
       {
          v.push_back(i);
       }
    }
}
 
int get(int n) 
{  
   int sum = 0; 
   while (n != 0) 
   { 
       sum = sum + n % 10; 
       n /= 10; 
   } 
   
   return sum; 
}
 
int reverse( int n )
{
    int rev = 0;
    while( n )
    {
        int rem = n % 10;
        rev = rev * 10 + rem;
        n /= 10;
    }
    
    return rev;
}
 
long long int subset_sum( vector< long long int > a, long long int n )
{
    long long int s1 = 0;
    for( long long int i = 0; i < n; i++ )
        s1 += a[i];
    long long int s = (s1);   
    bool dp[n+1][s+1];
    for( long long int i = 0; i <= n; i++ )
    dp[i][0] = true;
    for( long long int i = 1; i <= s; i++ )
    dp[0][i] = false;
    for( long long int i = 1; i <= n; i++ )
    {
        for( long long int j = 1; j <= s; j++ )
        {
            dp[i][j] = dp[i-1][j];
            if( a[i-1] <= j )
                dp[i][j] |= dp[i-1][j-a[i-1]];
        }
    }
    
    long long int m = INT_MAX;
    for( int i = s/2; i >= 0; i-- )
    {
        if( dp[n][i] == true )
        {
            m = s - 2*i;
            break;
        }
    }
    
    return m;
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
  
        if (arr[mid] == x) 
            return mid; 
  
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
            
        return binarySearch(arr, mid + 1, r, x); 
    } 
    
    return -1; 
}
 
bool prime( int n )
{
    if( n < 2 )
        return false;
    if( n < 4 )
        return true;
    if( n % 2 == 0 || n % 3 == 0 )
        return false;
    for( int i = 5; i*i <= n; i += 6 )
        if( n % i == 0 || n % ( i + 2 ) == 0 )
            return false;
            
    return true;
}
 
int find_next_prime( int n )
{
    while( 1 )
    {
        if( prime( n ) )
            return n;
        n++;
    }
}
 
bool isPowerOfTwo(int n) 
{ 
    if (n == 0) 
        return 0; 
    while (n != 1) 
    { 
        if (n%2 != 0) 
            return 0; 
        n = n/2; 
    } 
    return 1; 
} 

int solve( int n, int k )
{
    int dp[k+1][n+1];
        for( int i = 0; i <= k; i++ )
            dp[i][0] = 0;
        for( int i = 0; i <= n; i++ )
            dp[0][i] = 1;
        for( int i = 1; i <= k; i++ )
        {
            for( int j = 1; j <= n; j++ )
            {
                dp[i][j] = ( dp[i][j-1] + dp[i-1][j-1] ) % 1000000007;
            }
        }
        
        return dp[k][n];
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin >> t;
    while( t-- )
    {
        int n, k;
        cin >> n >> k;
        int a[n];
        for( int i = 0; i < n; i++ )
            cin >> a[i];
        map< int, int > mp;
        for( int i = 0; i < n; i++ )
            mp[a[i]]++;
        sort( a, a+n );
		reverse( a, a+n );
		int x = a[k-1];
		int count = 0;
		for( int i = 0; i < k; i++ )
		{
		    if( a[i] == x )
		        count++;
		}
         
        cout << solve( mp[x], count ) % 1000000007 << endl;
    }
}