#include #define Max(a,b) ((ab)&&(a=b)) #define rep(i,a,b) for(ll i=a,i##end=b;i<=i##end;++i) #define drep(i,a,b) for(ll i=a,i##end=b;i>=i##end;--i) #define erep(i,a) for(ll i=hd[a],y;(y=to[i]);i=nxt[i]) using namespace std; typedef long long ll; char C; inline ll rd() { ll res=0,f=1; while(C=getchar(),C<48||C>57)if(C=='-')f=0; do res=(res<<3)+(res<<1)+(C^48); while(C=getchar(),C>=48&&C<=57); if(f)return res; return -res; } ll a[2005],b[2005],dp[2005]; int main() { ll T=rd(); while(T--) { ll n=rd(),ans=0; rep(i,1,n)a[i]=rd(); rep(i,1,n)b[i]=rd(),b[i]+=b[i-1]; memset(dp,63,sizeof dp),dp[0]=0; rep(i,1,n)drep(j,n,1) if(b[i]>=dp[j-1]+a[i]){ Min(dp[j],dp[j-1]+a[i]); Max(ans,j); } cout<