#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];
    }
    int i = 0;
    int j = 1;
    int k = j;
    while (d > 0 && n > 1) {
      if (a[j] > 0 && j <= d && j < n) {
        a[i]++;
        a[j]--;
        d = d - j;
      } else if (j >= n) {
        break;
      } else {
        j++;
      }
    }
    cout << a[i] << endl;
  }
}
