#include <iostream>
using namespace std;
const int N=105;
int T;
int n,d;
int a[N];
int res;
int main()
{
cin>>T;
while(T--){
cin>>n>>d;
res=0;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(i!=1)
{
while(d>=(i-1)&&a[i])
{
d-=(i-1);
a[i]--;
res++;
}
}
}
cout<<res+a[1]<<endl;
}
//cout << "Hello world!" << endl;
return 0;
}