#include <bits/stdc++.h>
using namespace std;
int a[200];
int main(int argc, char const *argv[]) {
  int t;
  cin >> t;
  for (int index = 0; index < t; ++index) {
    int n, d;
    cin >> n;
    cin >> d;
    for (int i = 0; i < 100; ++i) {
      a[i] = 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    int ans = a[0];
    int j = 1;
    while (d > 0 && j < n) {
      if (a[j] == 0)
        j++;
      else {
        if (d - j >= 0) {
          ans++;
          a[j]--;
        }
        d -= j;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
