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