#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n), b(n);
    long long steps = 0;
    for (auto i = 0; i < n; i += 1) cin >> a[i];
    for (auto i = 0; i < n; i += 1) cin >> b[i];
    long long mina, minb;
    mina = *min_element(a.begin(), a.end());
    minb = *min_element(b.begin(), b.end());
    for (auto i = 0; i < n; i += 1) {
      long long x, y, u, v;
      u = a[i] - mina;
      v = b[i] - minb;
      x = max(0ll, u);
      y = max(0ll, v);
      long long z = min(x, y);
      steps += z;
      steps += (x - z);
      steps += (y - z);
    }
    cout << steps << "\n";
  }
  return 0;
}
