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