#include using namespace std; typedef long long ll; const int M=1e5+5; int n,tes,id; ll m,a[M*2],now,mx,ans; void solve(){ ans=now=mx=id=0; scanf("%d%lld",&n,&m); for(int i=1;i<=n;i++){scanf("%lld",&a[i]);a[i+n]=a[i];} for(int i=1;i<=n*2;i++){ now+=a[i]; if(now<0)now=0,id=i; mx=max(mx,now); if(mx>=m){printf("%d\n",(i-1)/n+1);return;} } now=mx=0;id=id%n; for(int i=id+1;i<=id+n;i++){ now+=a[i]; if(now<0){puts("-1");return;} mx=max(mx,now); } if(now<=0){puts("-1");return;} ans=((m-mx-1)/now+1); m=m-now*ans; for(int i=id+1;i<=id+n;i++){ now+=a[i]; if(now>=m){ans+=(i-1)/n;break;} } printf("%lld\n",ans+1); } int main() { scanf("%d",&tes); while(tes--)solve(); return 0; }