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