#include <iostream>
#include <vector>
using namespace std;
const int mod= 1e9 + 7;
typedef long long int ll;
ll pow(ll base, ll exp)
{
ll result = 1;
while (exp > 0)
{
if (exp % 2 == 1)
result = (result * base) % mod;
base = (base * base) % mod;
exp /= 2;
}
return result;
}
int main()
{
int T;
cin >> T;
while (T--)
{
int N, K;
cin >> N >> K;
vector<int> A(N);
int c = 0;
for (int i = 0; i < N; i++)
{
cin >> A[i];
if (A[i] == 1) c++;
}
if (c < K)
{
cout << 0 << endl;
continue;
}
ll tot = pow(2, N) - 1;
ll bad = 0;
if (K > 0)
{
bad = pow(2, N-c ) - 1;
}
ll result = (tot- bad + mod) % mod;
cout << result -1<< endl;
}
return 0;
}