#include <bits/stdc++.h>
using namespace std;
vector<string> vec_splitter(string s) {
  for (char& c : s) c = c == ',' ? ' ' : c;
  stringstream ss;
  ss << s;
  vector<string> res;
  for (string z; ss >> z; res.push_back(z))
    ;
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << "): ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
long long int power(long long int b, long long int e) {
  assert(e >= 0);
  if (e == 0) return 1;
  if (e % 2 == 1)
    return b * power(b * b, (e - 1) / 2);
  else
    return power(b * b, e / 2);
}
long long int power(long long int b, long long int e, long long int m) {
  assert(e >= 0);
  if (e == 0) return 1;
  if (e % 2 == 1)
    return b * power(((b % m) * (b % m)) % m, (e - 1) / 2, m) % m;
  else
    return power(((b % m) * (b % m)) % m, e / 2, m) % m;
}
int nDig(long long int n) {
  if (n < 0) n *= -1;
  if (n == 0)
    return 1;
  else
    return int(log10(n) + 1);
}
int lognk(long long int n, long long int k) {
  assert(n >= 0 and k >= 0 and k != 1);
  if (n == 0)
    return -1;
  else
    return lognk(n / k, k) + 1;
}
const long double pi = acos(-1);
constexpr int mod = 1e9 + 7;
void swagWaalaFunction() {
  long long int n, d, ans = 0;
  cin >> n >> d;
  long long int arr[n];
  for (long long int i = 0; i < (long long int)n; ++i) cin >> arr[i];
  while (d--) {
    for (long long int i = 0; i < (long long int)n - 1; ++i)
      if (arr[i + 1]) {
        arr[i]++;
        arr[i + 1]--;
        break;
      }
  }
  cout << arr[0] << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t = 1;
  cin >> t;
  while (t--) swagWaalaFunction();
  return 0;
}
