#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
int T, N, D, x, ans;
int main(int argc, char** argv) {
  scanf("%d", &T);
  for (int t = (0); t < (T); t++) {
    ans = 0;
    bool ok = false;
    scanf("%d%d", &N, &D);
    for (int i = (0); i < (N); i++) {
      scanf("%d", &x);
      if (ok) continue;
      if (x * i <= D) {
        D -= x * i;
        ans += x;
      } else {
        ans += D / i;
        ok = true;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
