#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 ;
}
f(k>cnt1){
cout<<"0"<<endl;
return;
}
ll ans=0;
for(ll i=0;i<=cnt2;i++){
ans=(ans%md+ncr(cnt2,i)%md)%md;
}
//cout<<ans<<endl;
ll sum=0;
for(ll i=k;i<=cnt1;i++){
sum=(sum%md)+(ncr(cnt1,i)%md)%md;
}
sum=(sum%md*ans%md)%md;
sum--;
if(cnt1==k){
if(cnt2!=0){
cout<<power(2,cnt2)-1<<endl;
return;
}
cout<<"0"<<endl;
return;
}
cout<<sum<<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;
}