#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t, n, d;
  cin >> t;
  while (t--) {
    cin >> n >> d;
    int arr[n];
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
    }
    if (n == 1) {
      cout << arr[0] << "\n";
      continue;
    }
    for (int i = 1; i < n; ++i) {
      while (arr[i] > 0 && d > 0) {
        if (i > d) break;
        arr[0]++;
        d -= i;
        arr[i] -= 1;
      }
    }
    cout << arr[0] << "\n";
  }
}
