#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int mod = 1e9 + 7;
const int maxn = 1e7;
struct mi {
int v;
explicit operator int() const { return v; }
mi() { v = 0; }
mi(long long x) : v(x % mod) { v += (v < 0) * mod; }
};
mi& operator+=(mi& a, mi b) {
if ((a.v += b.v) >= mod) a.v -= mod;
return a;
}
mi& operator-=(mi& a, mi b) {
if ((a.v -= b.v) < 0) a.v += mod;
return a;
}
mi operator+(mi a, mi b) { return a += b; }
mi operator-(mi a, mi b) { return a -= b; }
mi operator*(mi a, mi b) { return mi((long long)a.v * b.v); }
mi& operator*=(mi& a, mi b) { return a = a * b; }
mi pw(mi a, long long p) {
mi res = 1;
while (p > 0) {
if (p & 1) res *= a;
a *= a;
p >>= 1;
}
return res;
}
mi inv(mi a) {
return pw(a, mod - 2);
}
mi operator/(mi a, mi b) { return a * inv(b); }
vector<mi> fct(maxn + 1, 1);
void prefact() {
for (int i = 2; i <= maxn; ++i)
fct[i] = fct[i - 1] * i;
}
mi ncr(int n, int r) {
if (r < 0 or r > n) return 0;
return fct[n] * inv(fct[r] * fct[n - r]);
}
void solve() {
i64 n, k; cin >> n >> k;
vector<int> f (2);
vector<int> a (n); for (int i = 0; i < n; ++i) cin >> a[i], ++f[a[i]];
mi ans = 0;
for (int i = k; i < f[1]; ++i) {
ans += ncr(f[1], i) * pw(2, f[0]);
}
if (f[0]) ans += pw(2, f[0]) - 1;
cout << int(ans) << '\n';
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(nullptr);
prefact();
i64 T; cin >> T;
while(T--) solve();
return 0;
}