#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  os << "]";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, set<T> S) {
  os << "{ ";
  for (auto s : S) os << s << " ";
  return os << "}";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class L, class R>
ostream &operator<<(ostream &os, map<L, R> M) {
  os << "{ ";
  for (auto m : M) os << "(" << m.first << ":" << m.second << ") ";
  return os << "}";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, d;
    cin >> n >> d;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    long long ans = a[0];
    for (long long i = 1; i < n; i++) {
      if (a[i] == 0) continue;
      long long k = d / i;
      if (k == 0) break;
      if (k > a[i]) k = a[i];
      ans += k;
      d -= k * i;
    }
    cout << ans << "\n";
  }
  return 0;
}
