#include <bits/stdc++.h>
using namespace std;
void readtxt() {}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
int32_t main() {
  readtxt();
  fast();
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> a(n), b(n);
    long long int mina = 2147483647, minb = 2147483647;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      if (mina > a[i]) mina = a[i];
    }
    for (long long int i = 0; i < n; i++) {
      cin >> b[i];
      if (minb > b[i]) minb = b[i];
    }
    long long int ans = 0;
    for (long long int i = 0; i < n; i++) {
      ans += max(a[i] - mina, b[i] - minb);
    }
    cout << ans << endl;
  }
}
