#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N=2e5+10;
ll MOD = 1e9+7;
const int MAX = 1e5 + 5;
ll fact[MAX];
// Precompute factorials
void computeFactorials() {
fact[0] = 1;
for (int i = 1; i < MAX; ++i)
fact[i] = (fact[i - 1] * i) % MOD;
}
ll modInverse(ll a, ll m = MOD) {
ll res = 1;
ll b = m - 2;
while (b) {
if (b & 1) res = (res * a) % m;
a = (a * a) % m;
b >>= 1;
}
return res;
}
long long modPow(ll a,ll b){
ll ans = 1;
while(b>0){
if(b&1) ans=(ans*a)%MOD;
b>>=1;
a=(a*a)% MOD;
}
return ans;
}
ll nCr(int n, int r) {
if (r > n) return 0;
return fact[n] * modInverse(fact[r]) % MOD * modInverse(fact[n - r]) % MOD;
}
ll nPr(int n, int r) {
if (r > n) return 0;
return fact[n] * modInverse(fact[n - r]) % MOD;
}
void solve(){
ll ans = 0;
ll n,k;cin >> n>>k;
vector<int>p(n);
ll one = 0;
ll zero = 0;
for(int i = 0; i < n ; i++){
cin >> p[i];
if(p[i] == 0) zero++;
else one++;
}
ll nts = modPow(2,zero);
for(int i = k; i < one ; i++){
ans += (nCr(one,one-i)*nts);
ans %= MOD;
}
ll mt = nts-1;
ans += nCr(one,0)*mt;
ans %= MOD;
cout << ans << endl;
}
int main() {
computeFactorials();
int t; cin >> t;
while (t--)
{
solve();
}
return 0;
}