#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int M = 2e3 + 5;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const int sz = 18;
const double eps = 1e-10;
const double pi = acos(-1);
int n, m;
char str[N];
int f[N];
map<string, int> mm;
vector<string> v;
template <class T>
inline void read(T &x) {
  char c;
  x = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') x = -1;
  T res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
  x *= res;
}
int main() {
  int t;
  read(t);
  while (t--) {
    read(n);
    read(m);
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      int a;
      read(a);
      if (m >= (i - 1) * a) {
        ans += a;
        m -= (i - 1) * a;
      } else {
        ans += m / (i - 1);
        m = m % (i - 1);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
