#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  while (n--) {
    int n1, d, i;
    cin >> n1 >> d;
    vector<int> x(n1);
    for (int j = 0; j < n1; j++) {
      cin >> x[j];
    }
    if (n1 == 1) {
      cout << x[0] << endl;
    } else {
      for (i = 1; i < n1 && d > 0; i++) {
        if (x[i] != 0 && d >= i) {
          if (x[i] <= (d / i)) {
            x[0] += x[i];
            d -= x[i] * i;
            x[i] = 0;
          } else {
            x[0] += (d / i);
            d -= (d / i) * i;
            x[i] = x[i] - (d / i);
          }
        }
      }
      cout << x[0] << endl;
    }
  }
  return 0;
}
