#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n), b(n);
    for (long long i = 0; i <= n - 1; i++) cin >> a[i];
    for (long long i = 0; i <= n - 1; i++) cin >> b[i];
    long long mina = *min_element(a.begin(), a.end());
    long long minb = *min_element(b.begin(), b.end());
    long long s = 0;
    for (long long i = 0; i <= n - 1; i++) s += max(a[i] - mina, b[i] - minb);
    cout << s << "\n";
  }
}
