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