/**
* written by Binoy Barman .
**/
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifdef LOCAL
#include "unravel.hpp"
#else
#define dbg(...) 42
#endif
#define int long long
const int mod = 1e9 + 7, MAX = 5005;
vector<long long> fact(MAX + 1), inv_fact(MAX + 1);
long long power(long long a, long long b) { // (a ^ b) % mod
long long res = 1;
while (b) {
if (b & 1) res = (res * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return res;
}
void prec() {
fact[0] = 1;
for (int i = 1; i <= MAX; i++) {
fact[i] = fact[i - 1] * i % mod;
}
inv_fact[MAX] = power(fact[MAX], mod - 2);
for (int i = MAX - 1; i >= 0; i--) {
inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod;
}
}
long long nCr(int n, int r) {
if (r > n || r < 0) return 0;
return fact[n] * inv_fact[r] % mod * inv_fact[n - r] % mod;
}
int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
prec();
Too_Many_Jobs {
int n, k;
cin >> n >> k;
int one = 0, zero = 0;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
x ? one++ : zero++;
}
if (one < k) {
cout << 0 << endl;
} else {
int all = power(2, n) - 1;
int inv = 0;
for (int i = 0; i < k; i++) {
inv = (inv + (one ? nCr(one, i) : 0) + (zero ? nCr(zero, i) : 0)) % mod;
}
int ans = (all - inv + mod) % mod;
cout << ans << endl;
}
}
return 0;
}