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