#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e4 + 14;
const int INF = INT_MAX;
const int MAXC = 30;
const long long LLINF = 1e16 + 14;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    int d;
    scanf("%d", &d);
    int res;
    scanf("%d", &res);
    for (int i = 1; i < n; ++i) {
      int x;
      scanf("%d", &x);
      int need = i;
      int add = min(d / need, x);
      d -= add * need;
      res += add;
    }
    printf("%d\n", res);
  }
  return 0;
}
