#include <bits/stdc++.h>
using namespace std;
#define SC scanf
#define PF printf
#define ull unsigned long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sort_a(a) sort(a.begin(),a.end());
#define sort_d(a) sort(a.rbegin(),a.rend());
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define rev(s) reverse(s.begin(),s.end())
#define P(ok) cout << (ok ? "YES\n": "NO\n")
#define __Heart__ ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll> PII;
const int M = 1e9 + 7 ;
ll BigMod(ll n,ll p)
{
if(p == 0) return 1;
if( p % 2 == 0)
{
ll ret = BigMod(n, p/2);
return ((ret % M ) *(ret % M))% M;
}
else return ((n % M)*(BigMod(n, p-1 ) % M))% M;
}
ll nCrMod(ll n, ll r) {
if (r > n) return 0;
if (r == 0 || r == n) return 1;
ll Res = 1;
for (ll i = 0; i < r; ++i) {
Res *= (n - i);
Res %= M;
Res *= BigMod(i + 1, M - 2);
Res %= M;
}
return Res;
}
ll sumNcRtoN(ll n, ll r) {
ll totSum = BigMod(2, n);
ll subtractSum = 0;
ll currentCr = 1;
for (ll i = 0; i < r; ++i) {
subtractSum = (subtractSum + currentCr) % M;
currentCr = (currentCr * (n - i)) % M;
currentCr = (currentCr * BigMod(i + 1, M - 2)) % M;
}
return (totSum - subtractSum + M) % M;
}
void solve()
{
ll n , k , sum = 0 , a; cin >> n >> k ;
for(int i = 0 ; i < n ; i++) cin >> a , sum += a ;
if(sum < k){
cout << 0 << "\n" ;
}
else {
ll Ans = (BigMod(2 , n - sum) % M * (sumNcRtoN(sum , k) % M)) % M ;
Ans-- ;
cout << Ans << "\n" ;
}
}
int main()
{
__Heart__
int t ; cin >> t ; while(t--) solve() ;
}