#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int Max=2e5+10;
ll mod = 1e9+7;
#define printp(v) for(auto e:v) cout<<e.first<<" "<<e.second<<endl;
ll fact[Max+1] , factInv[Max+1];
// modular inverse b = (b)^-1 = Pow(b,m-2);
long long Pow(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;
}
// void prec(){
// fact[0] = 1;
// for(ll i = 1;i <= N; i++){
// fact[i] = (fact[i-1] * i) % mod;
// }
// factinv[N] = modPow(N,mod-2);
// for(ll i = N-1; i>=0; i--){
// factinv[i] = (factinv[i+1] * (i+1)) % mod ;
// }
// }
// ll nCr(ll n, ll r){
// if(r > n || r < 0 || n<0) return 0;
// return ((fact[n] * factinv[r]) % mod * factinv[n-r]) % mod;
// }
// ll nPr(ll n, ll r){
// if(n < r || r < 0 || n < 0) return 0;
// return ((fact[n] * factinv[n-r])) % mod;
// }
void build_fact() {
fact[0] = 1;
for(int i = 1; i < Max; i++)
{
fact[i] = 1LL * fact[i - 1] * i % mod;
}
factInv[Max - 1] = Pow(fact[Max - 1], mod - 2);
for(int i = Max - 2; i >= 0; i--)
{
factInv[i] = 1LL * factInv[i + 1] * (i + 1) % mod;
}
return;
}
ll nCr_mod(int n, int r) {
if(n < r or n < 0 or r < 0) return 0;
return 1LL * fact[n] * factInv[r] % mod * factInv[n - r] % mod;
}
int nPr_mod(int n, int r) { // nPr = nCr * r!
if(n < r or n < 0 or r < 0) return 0;
return (1LL * nCr_mod(n, r) * fact[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++;
}
if(one < k){
cout<<0 << endl;return;
}
ll nts = Pow(2,zero);
for(int i = k; i < one ; i++){
ans += (nCr_mod(one,one-i)*nts);
ans %= mod;
}
ll mt = nts-1;
ans += nCr_mod(one,0)*mt;
ans %= mod;
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
build_fact();
int t = 1; cin >> t;
while(t--){
solve();
}
return 0;
}