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