#include<bits/stdc++.h>
#define ll long long
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
int main(){
FAST;
int t ;cin>>t;
while(t--){
int co=0;
int n,m=0;cin>>n;
int a[n],b[n];
for (int i = 0 ; i<n;i++){
cin>>a[i];
}
for (int i =0;i<n;i++){
cin>>b[i];
}
for (int i=0;i<n;i++){
if(a[i]<=b[i])
m=max(m,b[i]-a[i]);
}
cout <<m<<endl;
}
}