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