#include <bits/stdc++.h>
using namespace std;
const int N = 200100;
int n, d, tc, a[200];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> tc;
  while (tc--) {
    cin >> n >> d;
    for (int(i) = int(1); i <= int(n); i++) {
      cin >> a[i];
    }
    for (int(i) = int(2); i <= int(n); i++) {
      if (!d) break;
      if (a[i]) {
        while (a[i] * (i - 1) > d) a[i]--;
        a[1] += a[i];
        d -= a[i] * (i - 1);
      }
    }
    cout << a[1] << '\n';
  }
}
