#include <bits/stdc++.h>
using namespace std;
long long n, k;
const long long MAX_N = 102, MAX_K = 1e5 + 2;
const long long mod = 1e9 + 7;
long long arr[MAX_N];
long long dp[MAX_N][MAX_K];
long long s[MAX_N][MAX_K];
long long Top_Down(long long i = n, long long candies = k) {
  if (i == 0) return (candies == 0);
  if (dp[i][candies] != -1) return dp[i][candies] % mod;
  long long ways = 0;
  for (long long x = 0; x <= arr[i]; ++x) {
    if (candies >= x) ways += (Top_Down(i - 1, candies - x) % mod);
  }
  return (dp[i][candies] = ways % mod);
}
long long Bottom_Up() {
  dp[0][0] = 1;
  for (long long j = 1; j <= k; ++j) dp[0][j] = 0;
  for (long long i = 1; i <= n; ++i) dp[i][0] = 1;
  for (long long i = 1; i <= n; ++i) {
    for (long long candies = 1; candies <= k; ++candies) {
      long long ways = 0;
      for (long long x = 0; x <= arr[i]; ++x) {
        if (candies >= x) ways += dp[i - 1][candies - x] % mod;
      }
      dp[i][candies] = ways % mod;
    }
  }
  return dp[n][k];
}
long long Bottom_Up2() {
  dp[0][0] = 1;
  for (long long j = 1; j <= k; ++j) dp[0][j] = 0;
  for (long long i = 1; i <= n; ++i) dp[i][0] = 1;
  long long i, j;
  for (i = 1; i <= n; ++i) {
    s[i - 1][0] = dp[i - 1][0];
    for (j = 1; j <= k; ++j) {
      s[i - 1][j] = (dp[i - 1][j] + s[i - 1][j - 1]) % mod;
    }
    for (j = 1; j <= k; ++j) {
      dp[i][j] = s[i - 1][j];
      if (j - arr[i] - 1 >= 0)
        dp[i][j] = (dp[i][j] - s[i - 1][j - arr[i] - 1] + mod) % mod;
    }
  }
  return dp[n][k] % mod;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    memset(dp, -1, sizeof(dp));
    cin >> n >> k;
    for (long long i = 1; i <= n; ++i) cin >> arr[i];
    cout << Bottom_Up2() % mod << "\n";
  }
}
