#include #define ll long long using namespace std; const int MAXN=2000+5; const int MOD=(1<<10)-1; int n,T; ll a[MAXN],b[MAXN]; ll dp[MAXN]; void solve() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",a+i); for(int i=1;i<=n;i++) scanf("%d",b+i),b[i]+=b[i-1]; for(int i=0;i<=n+1;i++) dp[i]=-1; dp[0]=1ll<<60; for(int i=n+1;i>1;i--) for(int j=n;j>=0;j--) { ll nd=min(dp[j]-a[i-1],b[i-1]-a[i-1]); if(nd<0) continue; dp[j+1]=max(nd,dp[j+1]); } for(int i=n;i>=0;i--) if(dp[i]!=-1) { printf("%d\n",i); break; } } int main() { scanf("%d",&T); while(T--) solve(); return 0; }