#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 500010;
int mod = 1e9 + 7;
int power(int a, int b, int M)
{
if (!b)
return 1;
int temp = power(a, b / 2, M);
temp = 1LL * temp * temp % M;
if (b % 2)
temp = 1LL * temp * a % M;
return temp;
}
int fact[N];
void pre()
{
fact[0] = 1;
for (int i = 1; i < N; i++)
{
fact[i] = 1LL * fact[i - 1] * i % mod;
}
}
ll npr(ll n, ll r)
{
if (r > n)
return 0;
ll res = fact[n];
res = (res * power(fact[n - r], mod - 2, mod)) % mod;
return res;
}
int ncr(int n, int r)
{
if (n < r)
return 0;
assert(n >= 0 && n < N && r >= 0 && r < N);
int ans = fact[n];
ans = 1LL * ans * power(fact[n - r], mod - 2, mod) % mod;
ans = 1LL * ans * power(fact[r], mod - 2, mod) % mod;
if (ans < 0)
ans += mod;
assert(ans >= 0 && ans < mod);
return ans;
}
int main()
{
pre();
int t, n, x,k;
cin >> t;
while (t--)
{
cin >> n>>k;
ll sum = 0, ze;
ll on = ze = 0;
for (int i = 0; i < n; i++)
{
cin >> x;
if (x == 1)
{
sum++;
on++;
}
else
{
ze++;
}
}
ll baki=sum-k;
if(baki<0)
{
cout<<0<<endl;
continue;
}
else
{
ll x=power(2,ze,mod);
x--;
ll ans=x;
for(ll i=1;i<=baki;i++)
{
ll z=ncr(on,i);
ans+=z;
ans%=mod;
ll pp=(1LL*x*z)%mod;
ans+=pp;
ans%=mod;
}
cout<<ans<<endl;
}
}
}