#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using lint = long long;
mt19937 rng(time(NULL));
lint Power(lint A, lint B, lint C) {
  if (!B) return 1;
  lint tmp = Power(A, B >> 1, C);
  return tmp * tmp % C * (B & 1 ? A : 1) % C;
}
int T, N, D, Ans;
int A[111];
int main() {
  cin >> T;
  while (T--) {
    cin >> N >> D;
    for (int i = 1; i <= N; ++i) cin >> A[i];
    Ans = A[1];
    for (int i = 2; i <= N; ++i) {
      while (D >= i - 1 && A[i]--) {
        Ans++;
        D -= i - 1;
      }
    }
    cout << Ans << '\n';
  }
  return 0;
}
