#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long a, n, d, t;
  cin >> a;
  while (a--) {
    cin >> n >> t;
    vector<long long> arr(n);
    for (auto &i : arr) cin >> i;
    long long sum = arr[0];
    for (long long i = 1; i < n; i++) {
      if (t < i) break;
      long long m = min(arr[i], t / i);
      sum += m;
      t -= m * i;
    }
    cout << sum << endl;
  }
  return 0;
}
