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