#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, d, sum = 0, k = 1;
    cin >> n >> d;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 1; i < n; i++) {
      if (a[i] * i >= d) {
        sum += d / i;
        break;
      } else if (a[i] * i < d && a[i] > 0) {
        sum += a[i];
        d -= a[i] * i;
      }
    }
    cout << sum + a[0] << endl;
  }
  return 0;
}
