#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n);
  long long na = 1e9, nb = 1e9;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
    na = min(na, a[i]);
  }
  for (long long i = 0; i < n; ++i) {
    cin >> b[i];
    nb = min(nb, b[i]);
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    long long d1, d2;
    d1 = a[i] - na;
    d2 = b[i] - nb;
    ans += max(d1, d2);
  }
  cout << ans << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  auto start = system_clock::now();
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  auto end = system_clock::now();
  cerr << "Time: " << duration_cast<milliseconds>(end - start).count() << "ms"
       << endl;
}
