#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  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) {
      cout << a[0] << endl;
      continue;
    }
    if (n == 2) {
      while (a[1] > 0 && d--) {
        a[1]--;
        a[0]++;
      }
      cout << a[0] << endl;
      continue;
    }
    int i = 1;
    while (d > 0 && i <= n - 1) {
      if (a[i] > 0 && i >= 1) {
        a[i]--;
        a[i - 1]++;
        d--;
        if (i != 0)
          i--;
        else
          i++;
      } else {
        i++;
      }
    }
    cout << a[0] << endl;
  }
}
