#include <bits/stdc++.h>
using namespace std;
#define TASK "test"
const int INF=1e9;
main()
{
freopen(TASK".in","r",stdin);
freopen(TASK".out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);
int T;
cin>>T;
while(T--)
{
int n,x;
cin>>n>>x;
vector<int> a(n);
for(int i=0;i<n;i++) cin>>a[i];
deque<pair<int,int>> que;
int ans=INF;
int cur=0;
for(int i=0;i<n;i++)
{
cur+=a[i];
while(!que.empty() && que.back().first>cur) que.pop_back();
que.push_back({cur,i});
while(que.size()>2 && cur-que[1].first>=x) que.pop_front();
if(que.front().second!=i && cur-que.front().first>=x) ans=min(ans,i-que.front().second);
if(a[i]>=x) ans=1;
}
if(ans==INF) cout<<-1<<endl;
else cout<<ans<<endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBUQVNLICJ0ZXN0IgoKY29uc3QgaW50IElORj0xZTk7CgptYWluKCkKewogICAgZnJlb3BlbihUQVNLIi5pbiIsInIiLHN0ZGluKTsKICAgIGZyZW9wZW4oVEFTSyIub3V0IiwidyIsc3Rkb3V0KTsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGludCBUOwogICAgY2luPj5UOwogICAgd2hpbGUoVC0tKQogICAgewogICAgICAgIGludCBuLHg7CiAgICAgICAgY2luPj5uPj54OwogICAgICAgIHZlY3RvcjxpbnQ+IGEobik7CiAgICAgICAgZm9yKGludCBpPTA7aTxuO2krKykgY2luPj5hW2ldOwogICAgICAgIGRlcXVlPHBhaXI8aW50LGludD4+IHF1ZTsKICAgICAgICBpbnQgYW5zPUlORjsKICAgICAgICBpbnQgY3VyPTA7CiAgICAgICAgZm9yKGludCBpPTA7aTxuO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGN1cis9YVtpXTsKICAgICAgICAgICAgd2hpbGUoIXF1ZS5lbXB0eSgpICYmIHF1ZS5iYWNrKCkuZmlyc3Q+Y3VyKSBxdWUucG9wX2JhY2soKTsKICAgICAgICAgICAgcXVlLnB1c2hfYmFjayh7Y3VyLGl9KTsKICAgICAgICAgICAgd2hpbGUocXVlLnNpemUoKT4yICYmIGN1ci1xdWVbMV0uZmlyc3Q+PXgpIHF1ZS5wb3BfZnJvbnQoKTsKICAgICAgICAgICAgaWYocXVlLmZyb250KCkuc2Vjb25kIT1pICYmIGN1ci1xdWUuZnJvbnQoKS5maXJzdD49eCkgYW5zPW1pbihhbnMsaS1xdWUuZnJvbnQoKS5zZWNvbmQpOwogICAgICAgICAgICBpZihhW2ldPj14KSBhbnM9MTsKICAgICAgICB9CiAgICAgICAgaWYoYW5zPT1JTkYpIGNvdXQ8PC0xPDxlbmRsOwogICAgICAgIGVsc2UgY291dDw8YW5zPDxlbmRsOwogICAgfQp9CgoK