#include <bits/stdc++.h>
using namespace std;
int n, k;
//int a[n+1];

int main()
{   
    int t;
    cin>>t;
    while(t--)
    {
    cin>>n;cin>>k;
    int a[n+1];
    for(int i=1;i<=n;++i)
    {
        cin>>a[i]; 
    }
    const int mod = 1000000007;
    long dp[n+1][k+1]={0};
    for(int i=1;i<=n;++i)
    {dp[i][0]=1;}
    for(int j=1;j<=a[1];++j)
        dp[1][j]=dp[1][j-1]+1;
    for(int j=a[1]+1;j<=k;++j)
        dp[1][j]=dp[1][j-1];
    for(int i=2;i<=n;++i)
    {
        for(int j=1;j<=k;++j)
            {   if(j-a[i]-1>=0)
                dp[i][j]=((dp[i-1][j]-dp[i-1][j-a[i]-1]+mod)%mod+dp[i][j-1])%mod;
            
                else
                dp[i][j]= (dp[i-1][j]+dp[i][j-1])%mod;
            }
    }
   if(k==0) cout<<dp[n][k]<<endl;
   else
   cout<<(dp[n][k]-dp[n][k-1]+mod)%mod<<endl;

}
}


