#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, d;
    cin >> n >> d;
    int A[n];
    for (int i = 0; i <= n - 1; i++) cin >> A[i];
    for (int i = 1; i <= n - 1; i++) {
      A[0] += min(A[i], d / i);
      d -= min(A[i], d / i) * i;
      if (!d) break;
    }
    cout << A[0] << endl;
  }
}
