#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll t;
  t = 1;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    ll a[n];
    ll mna = INT_MAX, mnb = INT_MAX;
    for (ll i = 0; i < n; i++) cin >> a[i], mna = min(mna, a[i]);
    ll b[n];
    for (ll i = 0; i < n; i++) cin >> b[i], mnb = min(mnb, b[i]);
    ll ans = 0;
    for (ll i = 0; i < n; i++) {
      if (a[i] >= mna || b[i] >= mnb) ans += (max(a[i] - mna, b[i] - mnb));
    }
    cout << ans << "\n";
  }
}
