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