#include <bits/stdc++.h>
using namespace std;
long long int bg = pow(10, 10) + 7;
vector<vector<long long int> > vec(500004);
long long int vis[500004], temp = 1;
vector<pair<long long int, long long int> > ans(500004);
void dfs(long long int i) {
  long long int j;
  reverse(vec[i].begin(), vec[i].end());
  for (j = 0; j < vec[i].size(); j++) {
    if (vis[vec[i][j]] == 0) ans[vec[i][j]].first = ++temp;
  }
  ans[i].second = ++temp;
  vis[i] = 1;
  reverse(vec[i].begin(), vec[i].end());
  for (j = 0; j < vec[i].size(); j++)
    if (vis[vec[i][j]] == 0) dfs(vec[i][j]);
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int i, j = 0, n, s;
    cin >> n >> s;
    long long int arr[n];
    for (i = 0; i < n; i++) cin >> arr[i];
    set<pair<long long int, long long int> > set1;
    set1.insert(make_pair(0, 0));
    long long int ans = 0;
    for (i = 0; i < n; i++) {
      j += arr[i];
      long long int f = (--set1.end())->first;
      if (j - f <= s) {
        ans = (--set1.end())->second;
      }
      if (j <= s) {
        ans = 0;
      }
      set1.insert(make_pair(arr[i], i + 1));
    }
    cout << ans << '\n';
  }
  return 0;
}
