#include <bits/stdc++.h>
using namespace std;
int main() {
  int d, N, t;
  cin >> t;
  while (t--) {
    cin >> N >> d;
    int arr[N];
    for (int i = 0; i < N; ++i) cin >> arr[i];
    int j = 1;
    int counter = arr[0];
    if (N > 1)
      while (j < N) {
        while (d - j >= 0 && arr[j]--) {
          counter++;
          d -= j;
        }
        if (d <= 0) break;
        j++;
      }
    cout << counter << endl;
  }
  return 0;
}
