#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
const long long M = 1e16;
const int N = 1e5 + 100;
int a[N];
int main() {
  int num;
  scanf("%d", &num);
  while (num--) {
    int n, m;
    scanf("%d%d", &n, &m);
    bool flag = true;
    int sum = 0, maxx = 0, now = 0, num;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (flag) {
        if (sum + a[i] > m) {
          flag = false;
        } else {
          sum += a[i];
          if (a[i] > maxx) {
            maxx = a[i];
            num = i;
          }
          now = i;
        }
      }
    }
    if (now == n) {
      printf("0\n");
    } else {
      int j = now, jj = sum - maxx;
      while (j + 1 <= n && a[j + 1] + jj <= m) {
        j++;
        jj += a[j];
      }
      int k = now + 1, kk = sum;
      while (k + 1 <= n && a[k + 1] + kk <= m) {
        k++;
        kk += a[k];
      }
      if (j - 1 > k - 1 && j - 1 > now) {
        printf("%d\n", num);
      } else if (k - 1 > now) {
        printf("%d\n", now + 1);
      } else {
        printf("0\n");
      }
    }
  }
  return 0;
}
