#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  long long a[n];
  long long b[n];
  long long ma = INT_MAX, mb = INT_MAX;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    ma = min(ma, a[i]);
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    mb = min(mb, b[i]);
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long d1 = a[i] - ma;
    long long d2 = b[i] - mb;
    long long shared = min(d1, d2);
    long long sep = abs(d1 - d2);
    ans += shared + sep;
  }
  cout << ans << endl;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) solve();
  return 0;
}
