#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void pn(Arg1&& arg1) {
  cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  pn(args...);
}
template <typename Arg1>
void ps(Arg1&& arg1) {
  cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) {
  cout << arg1 << " ";
  ps(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
  cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
  cin >> arg1;
  read(args...);
}
void LOCAL();
void solve() {
  long long n, d;
  cin >> n >> d;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    pn(a[0]);
    return;
  }
  long long ans = 0;
  for (long long i = 1; i < n; i++) {
    if (a[i] > 0) {
      if (i * a[i] <= d) {
        ans += (i * a[i]) / i;
        d -= (i * a[i]);
      } else {
        long long kk = i * a[i];
        while (kk > d) {
          kk -= i;
        }
        ans += (kk) / i;
        d -= (kk);
      }
    }
  }
  pn(ans + a[0]);
}
int main() {
  clock_t z = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  fprintf(stderr, "Total Time: %.7f\n", (double)(clock() - z) / CLOCKS_PER_SEC),
      fflush(stderr);
  return 0;
}
void LOCAL() {}
