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