#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
using namespace std;
string reverse_str(string str) {
  long long n = str.length();
  for (long long i = 0; i < n / 2; i++) swap(str[i], str[n - i - 1]);
  return str;
}
bool check_is_palindrome(string s) { return (s == reverse_str(s)); }
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, d;
    cin >> n >> d;
    vector<long long> arr(n);
    for (long long i = 0; i < n; ++i) cin >> arr[i];
    if (n == 1) {
      cout << arr[0] << "\n";
      continue;
    }
    long long ind = 1;
    while (d > 0 && ind < n) {
      if (arr[ind] == 0) {
        ind++;
        continue;
      }
      long long temp = d / ind;
      if (temp <= arr[ind]) {
        d = 0;
        arr[0] = arr[0] + temp;
      } else {
        arr[0] = arr[0] + arr[ind];
        d = d - ind * arr[ind];
      }
      ind++;
    }
    cout << arr[0] << "\n";
  }
  return 0;
}
