#include <bits/stdc++.h>
#pragma GCC optimization("unroll-loops")
#pragma GCC optimization("O2")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, d, ans = 0;
    cin >> n >> d;
    for (int i = 0; i < n; i += 1) {
      int a;
      cin >> a;
      if (i == 0) {
        ans = a;
      } else {
        if (i * a <= d) {
          d -= i * a;
          ans += a;
        } else {
          ans += d / i;
          d = 0;
        }
      }
    }
    cout << ans << endl;
  }
}
