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