#include <bits/stdc++.h>
int main() {
  int rows, days, a[105];
  int test_cases;
  scanf("%d", &test_cases);
  while (test_cases--) {
    scanf("%d %d", &rows, &days);
    for (int i = 1; i <= rows; i++) {
      scanf("%d", &a[i]);
    }
    while (days--) {
      for (int i = 2; i <= rows; i++) {
        if (a[i] > 0) {
          a[i]--;
          a[i - 1]++;
          break;
        }
      }
    }
    printf("%d\n", a[1]);
  }
}
