#include <bits/stdc++.h>
using namespace std;
int T, n, d, a[110];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  while (T--) {
    cin >> n >> d;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (i == 1)
        ans += a[i];
      else {
        while (d - (i - 1) >= 0 && a[i] > 0) {
          d -= i - 1;
          ans++;
          a[i]--;
        }
      }
    }
    cout << ans << '\n';
  }
  getchar();
  getchar();
  return 0;
}
