/*
* Copyright (c) 2024 Emon Thakur
* All rights reserved.
*/
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using minheap = priority_queue<long long, vector<long long>, greater<long long>>;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key
#define ll long long
#define ld long double
#define MOD 1000000007
#define pie 2*(acos(0.0))
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
#define endl '\n'
#define lcm(a,b) (a*b)/(__gcd<ll>(a,b))
#define print(v) for(auto e:v) cout<<e<<" "; cout<<endl;
#define printp(v) for(auto e:v) cout<<e.first<<" "<<e.second<<endl;
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(),v.rend())
#define life_is_a_race ios::sync_with_stdio(false); cin.tie(nullptr);
// Modulo nCr
const int Max = 2e5 + 5;
ll fact[Max], factInv[Max];
ll mod = 1e9+7;
ll Pow(ll a, ll b)
{
ll ans = 1;
while (b)
{
if (b & 1) ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
ans += mod;
ans %= mod;
return ans;
}
void build_fact() {
fact[0] = 1;
for(int i = 1; i < Max; i++)
{
fact[i] = 1LL * fact[i - 1] * i % mod;
}
factInv[Max - 1] = Pow(fact[Max - 1], mod - 2);
for(int i = Max - 2; i >= 0; i--)
{
factInv[i] = 1LL * factInv[i + 1] * (i + 1) % mod;
}
return;
}
ll nCr_mod(int n, int r) {
if(n < r or n < 0 or r < 0) return 0;
return 1LL * fact[n] * factInv[r] % mod * factInv[n - r] % mod;
}
int nPr_mod(int n, int r) { // nPr = nCr * r!
if(n < r or n < 0 or r < 0) return 0;
return (1LL * nCr_mod(n, r) * fact[r]) % mod;
}
void solve(int tc)
{
//cout<<"Case "<<tc<<": ";
ll n,k; cin >> n >> k;
ll a[n],sum=0;
for(int i=0;i<n;i++) cin >> a[i], sum+=a[i];
if(sum<k)
{
cout<<0<<endl;
return;
}
ll ans = 0, one;
ll z = Pow(2,n-sum);
ans = z-1;
for(ll i=sum-1;i>=k;i--)
{
one = sum-i;
ans += ((nCr_mod(sum,one) * z) % mod);
ans = ans%mod;
}
cout << ans % mod << endl;
}
int main()
{
life_is_a_race
build_fact();
int t=1;
cin>>t;
for(int i=1;i<=t;i++) solve(i);
}