#include <iostream>
#include "algorithm"
#include "cmath"
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tt;
cin >> tt;
while (tt--) {
int size;
cin >> size;
int arrw[size];
int arrc[size];
for (int i = 0; i < size; i++) {
cin >> arrw[i];
}
for (int j = 0; j < size; j++) {
cin >> arrc[j];
}
int max = INT_MAX;
for (int k = 0; k < size; k++) {
if (max > arrw[k] - arrc[k]) {
max = arrw[k] - arrc[k];
}
}
cout << abs(max) << endl;
}
}