#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #define re register #define ll long long usingnamespace std;
constint N=1e6+10;
ll d[2*N],sum[2*N]; int hh,tt,q[2*N]; char c;
voidinsert(int x) { while (hh<=tt&&sum[q[tt]]>=sum[x]) tt--; q[++tt]=x; return; }
voidget(int &x) { while ((c=getchar())<'0'||c>'9') ; x=c-'0'; while ((c=getchar())>='0'&&c<='9') x=(x<<3)+(x<<1)+c-'0'; }
intmain() { // freopen("randdata.in","r",stdin); // freopen("myans.out","w",stdout); re int cas,n,x; get(cas); while (cas--) { get(n); for (re int i=1;i<=n;++i) get(x),d[i]=x; for (re int i=1;i<=n;++i) { get(x); d[i]-=x; } for (re int i=1;i<=n;++i) d[i+n]=d[i]; for (re int i=1;i<=2*n;++i) sum[i]=sum[i-1]+d[i];//,cout<<sum[i]<<' '; hh=1;tt=0; for (re int i=1;i<=n;++i) insert(i); re bool flag=0; for (re int i=1;i<=n;++i) { while (hh<=tt&&q[hh]<i) hh++; insert(i+n-1); // printf("%d %d\n",hh,tt); if (sum[i-1]<=sum[q[hh]]) { printf("%d\n",i); flag=1; break; } } if (!flag) puts("Failed!"); } return0; }