#include #define fo(i,a,b) for(int i=a;i<=b;++i) #define fod(i,a,b) for(int i=a;i>=b;--i) #define max(q,w) ((q)>(w)?(q):(w)) #define min(q,w) ((q)<(w)?(q):(w)) using namespace std; typedef long long LL; const int N=2050; const LL INF=1e18; int read(int &n) { int q=1;n=0;char ch=' '; for(;ch!='-'&&(ch<'0'||ch>'9');ch=getchar()); if(ch=='-')q=-1,ch=getchar(); for(;ch<='9'&&ch>='0';ch=getchar())n=(n<<1)+(n<<3)+ch-48; return n; } int n,m,ans; int a[N]; LL b[N]; LL f[N][N]; int main() { int q,w,_; read(_); while(_--) { read(n); fo(i,1,n)read(a[i]); fo(i,1,n)b[i]=b[i-1]+read(q); fo(i,0,n)fo(j,0,n)f[i][j]=INF; f[0][0]=ans=0; fo(i,0,n-1)fo(j,0,i)if(f[i][j]