#include <bits/stdc++.h>
using namespace std;
int a[105];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, d;
    scanf("%d%d", &n, &d);
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    for (int i = 1; i < n; i++) {
      if (a[i] * i >= d) {
        a[0] += d / i;
        break;
      }
      a[0] += a[i];
      d -= a[i] * i;
    }
    printf("%d\n", a[0]);
  }
  return 0;
}
