#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const int maxn = 1e2 + 10;
int n, d;
int a[maxn];
int main() {
  int T;
  cin >> T;
  while (T--) {
    cin >> n >> d;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int ans = a[0];
    for (int i = 1; i < n; i++) {
      while (d - i >= 0 && a[i] > 0) {
        ans++;
        d -= i;
        a[i]--;
      }
      if (d == 0) break;
    }
    cout << ans << endl;
  }
  return 0;
}
