#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <class T>
inline bool chmin(T &x, const T &y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmax(T &x, const T &y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
struct IOSET {
  IOSET() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(10);
  }
} ioset;
void solve();
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < (t); ++i) solve();
  return 0;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 0; i < (n); ++i) cin >> b[i];
  int mna = inf, mnb = inf;
  for (int i = 0; i < (n); ++i) {
    chmin(mna, a[i]);
    chmin(mnb, b[i]);
  }
  ll ans = 0;
  for (int i = 0; i < (n); ++i) ans += max(a[i] - mna, b[i] - mnb);
  cout << ans << "\n";
  return;
}
