#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int haybales, d, i;
    cin >> haybales >> d;
    int a[haybales];
    for (i = 0; i < haybales; i++) {
      cin >> a[i];
    }
    for (i = 1; i < haybales; i++) {
      int temp = a[i] * i;
      if (a[i] > 0 && temp <= d) {
        a[0] += (temp / i);
        d -= temp;
      } else if (a[i] > 0 && d >= i) {
        do {
          temp = temp - i;
        } while (temp > d);
        a[0] += (temp / i);
        d -= temp;
      }
    }
    cout << a[0] << "\n";
  }
  return 0;
}
