#include <bits/stdc++.h>
using namespace std;
void func() {
  long long int n, d;
  cin >> n >> d;
  vector<long long int> arr(n);
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  long long int cnt = 1;
  while (d >= cnt and cnt < n) {
    if (arr[cnt] == 0) {
      cnt++;
    } else {
      d -= cnt;
      arr[0]++;
      arr[cnt]--;
    }
  }
  cout << arr[0] << "\n";
}
int main() {
  long long int T;
  cin >> T;
  for (long long int _ = 0; _ < T; _++) func();
}
