#include <bits/stdc++.h>
using namespace std;
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, d, start, x, ans = 0, i, r = 0;
    cin >> n >> d;
    cin >> start;
    ans += start;
    for (i = 1; i < n; i++) {
      cin >> x;
      if (d - i * x >= 0 && r == 0) {
        d = d - i * x;
        ans += x;
      } else if (r == 0) {
        ans += d / i;
        r = 1;
      }
    }
    cout << ans << endl;
  }
}
