import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void solve() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1].to!long;
    auto A = readln.split.map!(to!long).array;
    long mx = -1;
    int mxi = -1;
    long sm = 0;
    bool erased = false;
    int skipped = -1;
    foreach (i, a; A) {
        if (sm + a <= M) {
            sm += a;
            if (a >= mx) {
                mx = a;
                mxi = i.to!int;
            }
        } else if (!erased) {
            if (a >= mx) {
                mx = a;
                mxi = i.to!int;
            }
            if (sm + a - mx <= M) {
                sm += a - mx;
                erased = true;
                skipped = mxi;
            } else {
                break;
            }
        } else {
            break;
        }
    }
    writeln(skipped + 1);
}

void main() {
    auto T = readln.chomp.to!int;
    while (T--) solve;
}