#include <bits/stdc++.h>
using namespace std;
const int mx = 2e5 + 6;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, d;
    cin >> n >> d;
    vector<int> a(n);
    for (long long(i) = 0; (i) < (n); ++(i)) cin >> a[i];
    int ans = 0;
    for (int i = 1; i < n; ++i) {
      int res = a[i] * i;
      if (res >= d) {
        int ak = d / i;
        ans += ak;
        break;
      } else {
        ans += a[i];
        d -= a[i] * i;
      }
    }
    cout << ans + a[0] << '\n';
  }
}
