#include <bits/stdc++.h>
//#define ll long long int
using namespace std;
typedef long long int ll;
priority_queue<int, vector<int>, greater<int>> pq;
const ll md = 1e9 + 7;
const ll md1 = 998244353;
map<ll, vector<ll>> tree;
//map<ll, int> mp;
ll dp[200001];
ll mp(ll x,ll y,ll p){
ll res=1;
x=x%p;
while(y>0){
if(y&1)res=(res*x)%p;
y=y>>1;
x=(x*x)%p;
}
return res;
}
ll ncr(ll n,ll r){
ll x=dp[n];
ll y=(dp[n-r]*dp[r])%md;
x=((x%md)*(mp(y,md-2,md)%md))%md;
return x;
}
ll power(ll base,ll pw){
ll res=1;
while(pw>0){
if(pw%2==0){
base=((base%md)*(base%md))%md;
pw/=2;
}
else{
res=((res%md)*(base)%md)%md;
pw--;
}
}
return res;
}
void sufi() {
ll n,k;
cin>>n>>k;
ll ara[n+1];
ll cnt1=0;
ll cnt2=0;
for(int i=1;i<=n;i++){
cin>>ara[i];
if(ara[i]==1)cnt1++;
else cnt2++;
}
if(k==0){
ll ans=0;
for(ll i=0;i<=n;i++)
ans=((ans%md)+ncr(n,i))%md;
cout<<ans<<endl;
return ;
}
ll ans=0;
for(ll i=k;i<=cnt1;i++){
ans=((ans%md)+ncr(cnt1,i))%md;
}
ll tmp=power(2ll,cnt2);
ans=((ans%md)*tmp%md)%md;
ans=(ans-1+md)%md;
cout<<ans<<endl;
}
int main() {
int t;
cin>>t;
dp[1]=1;
dp[0]=1;
for(ll i=2;i<=200000;i++){
dp[i]=((i%md)*(dp[i-1]%md))%md;
}
while (t--) {
sufi();
tree.clear();
//mp.clear();
}
return 0;
}