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