#include <bits/stdc++.h>
using namespace std;
struct customComparator {
  bool operator()(const int& lhs, const int& rhs) const { return false; }
};
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[105];
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    while (d--) {
      for (int i = 1; i < n; ++i) {
        if (a[i] > 0) {
          a[i]--;
          a[i - 1]++;
          break;
        }
      }
    }
    cout << a[0] << '\n';
  }
  return 0;
}
