#include <bits/stdc++.h>
using namespace std;
void Solve() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
int answer = 0;
for (int i = 0; i < n; ++i) {
int b;
cin >> b;
answer = max(answer, b - a[i]);
}
cout << answer << "\n";
}
int main() {
int t;
cin >> t;
while (t--) {
Solve();
}
return 0;
}