#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, t1, d1 = 0;
  cin >> t;
  t1 = t;
  int a1[t];
  while (t--) {
    int n, d;
    cin >> n >> d;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    int k = 1;
    int s = a[0];
    for (int i = 1; i < n;) {
      if (a[i] == 0) {
        i++;
      } else {
        if (d >= i) {
          d -= i;
          a[i]--;
          s++;
          if (d == 0) break;
        } else
          break;
      }
    }
    a1[d1++] = s;
  }
  for (int i = 0; i < t1; i++) cout << a1[i] << "\n";
}
