#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a * (b / gcd(a, b));
}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
int a[101];
int main() {
  int tc;
  scanf("%d", &tc);
  while (tc--) {
    int n, d;
    scanf("%d%d", &n, &d);
    for (int(i) = (0); (i) <= (n - 1); (i) += (1)) scanf("%d", a + i);
    int ans = a[0];
    for (int(i) = (1); (i) <= (n - 1); (i) += (1)) {
      while (d >= i && a[i] > 0) {
        ans++;
        a[i]--;
        d -= i;
      }
    }
    printf("%d\n", ans);
  }
}
