#include <stdio.h>
int main(){
int t,n,i,j,k,l,sort,count=0;
scanf("%d",&t);
for(i = 0;i<t;i++){
scanf("%d",&n);
int a[n],b[n],diff[n];
for(j = 0;j<n;j++){
scanf("%d",&a[j]);
}
for(j = 0;j<n;j++){
scanf("%d",&b[j]);
}
for(j = 0;j<n;j++){
diff[j]=b[j]-a[j];
for(k = 0;k<n;k++){
for(l = k+1;l<n;l++){
if(diff[k]>diff[l]){
sort=diff[k];
diff[k]=diff[l];
diff[l]=sort;
}
}
}
}
if(diff[n-1]>0){
count = diff[n-1];
printf("%d",count);
}
else{
printf("0");
}
printf("\n");
}
return 0;
}