#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t, n, d;
  cin >> t;
  int cnt = 0;
  int item;
  int c = 0;
  for (int i = 0; i < t; ++i) {
    cin >> n >> d;
    cin >> cnt;
    for (int j = 1; j < n; ++j) {
      cin >> item;
      if (d > 0) {
        c = min(item, d / j);
        cnt += c;
        d -= c * j;
      }
    }
    cout << cnt << '\n';
  }
  return 0;
}
