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