#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
template <typename T>
void read(T &x) {
  int p = 1;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - 48;
    c = getchar();
  }
  x *= p;
}
int a[N];
int main() {
  int T, d, n;
  read(T);
  while (T--) {
    read(n);
    read(d);
    for (int i = 1; i <= n; i++) read(a[i]);
    for (int i = 2; i <= n; i++) {
      if (d >= a[i] * (i - 1))
        d -= a[i] * (i - 1), a[1] += a[i];
      else {
        a[1] += d / (i - 1);
        break;
      }
    }
    cout << a[1] << "\n";
  }
  return 0;
}
