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