#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  int a[110];
  cin >> t;
  int n, k;
  while (t--) {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    int num = 1;
    while (k >= num && n > 1 && k > 0) {
      if (num == n) break;
      if (a[num] != 0) {
        k -= num;
        a[num]--;
        a[0]++;
      }
      if (a[num] == 0) num++;
    }
    cout << a[0] << endl;
  }
}
