#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
inline int D() {
  int m;
  cin >> m;
  return m;
}
inline long long lD() {
  long long m;
  cin >> m;
  return m;
}
inline double dD() {
  double m;
  cin >> m;
  return m;
}
int a[1006];
int main() {
  int t = D();
  while (t--) {
    int n = D(), d = D();
    for (int i = 0; i < n; ++i) {
      a[i] = D();
    }
    for (int i = 1; i < n; ++i) {
      if (d != 0) {
        while (a[i] != 0 && d) {
          if (i <= d) a[0]++;
          a[i]--;
          d -= i;
        }
      } else
        break;
    }
    cout << a[0] << endl;
  }
}
