#include <bits/stdc++.h>
#ifdef LOCAL
#include "template.cpp.h"
#else
#define debug(...)
#endif
#define int long long
using namespace std;
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';
template<int MOD>
class ModNum {
int val;
public:
ModNum(int val_ = 0) : val(val_ % MOD) {}
operator int() const { return val; }
ModNum pow(int p) const {
ModNum res = 1;
for (ModNum base = val; p > 0; p >>= 1, base *= base)
if (p & 1LL) res *= base;
return res;
}
ModNum inv() const {
static_assert(MOD >= 2);
assert (val != 0);
return pow(MOD - 2);
}
ModNum operator+(const ModNum &other) const { return (val + other.val) % MOD; }
ModNum operator-(const ModNum &other) const { return (val + MOD - other.val) % MOD; }
ModNum operator*(const ModNum &other) const { return (val * other.val) % MOD; }
ModNum operator/(const ModNum &other) const { return (*this) * other.inv(); }
ModNum &operator+=(const ModNum &other) { return *this = *this + other; }
ModNum &operator-=(const ModNum &other) { return *this = *this - other; }
ModNum &operator*=(const ModNum &other) { return *this = *this * other; }
ModNum &operator/=(const ModNum &other) { return *this = *this / other; }
bool operator==(const ModNum &other) const { return val == other.val; }
friend ModNum operator+(int a, const ModNum &b) { return ModNum(a) + b; }
friend ModNum operator-(int a, const ModNum &b) { return ModNum(a) - b; }
friend ModNum operator*(int a, const ModNum &b) { return ModNum(a) * b; }
friend ModNum operator/(int a, const ModNum &b) { return ModNum(a) / b; }
friend bool operator==(int a, const ModNum &b) { return ModNum(a) == b; }
friend ostream &operator<<(ostream &os, const ModNum &num) { return os << num.val; }
friend istream &operator>>(istream &is, ModNum &num) { return is >> num.val; }
};
const int P = 1e9 + 7;
using mint = ModNum<P>;
//fact
vector<mint> fact(1, 1);
vector<mint> inv_fact(1, 1);
mint C(int n, int k) {
if (k < 0 || k > n) return 0;
while (fact.size() < n + 1) {
fact.push_back(fact.back() * (mint) fact.size());
inv_fact.push_back(mint(1) / fact.back());
}
return fact[n] * inv_fact[k] * inv_fact[n - k];
}
void shelby() {
int n, k;
cin >> n >> k;
vector<int> cnt(2);
for (int i = 1; i <= n; ++i) {
int x;
cin >> x;
cnt[x] += 1;
}
mint ans = 0, mul = mint(2).pow(cnt[0]);
for (int i = k; i <= cnt[1]; ++i) ans += C(cnt[1], i) * (mul - mint(i == cnt[1]));
cout << ans << '\n';
}
signed main() {
cin.tie(0)->ios_base::sync_with_stdio(0);
int t = 1;
cin >> t;
for (int _ = 1; _ <= t; ++_) {
// cout << "Case " << _ << ": ";
shelby();
}
}