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