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