#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int t;
int a[N];
int main() {
cin >> t;
while (t -- ) {
int n, d;
cin >> n >> d;
for (int i = 1; i <= n; i ++ ) cin >> a[i];
for (int i = 2; i <= n; i ++ )
while (a[i] && d) {
int t = i - 1;
if (d >= t) {
a[1] ++, a[i] --;
d -= t;
}
else break;
}
cout << a[1] << endl;
}
return 0;
}