#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
int T;
cin >> T;
while (T -- )
{
int n, d;
cin >> n >> d;
int res = 0;
for (int i = 0; i < n; i ++ )
{
int x;
cin >> x;
if (!i) res += x;
else
{
int t = min(x, d / i);
res += t;
d -= t * i;
}
}
cout << res << endl;
}
return 0;
}