#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const long long mod = 1e9 + 7;
const int mxN = 5e5 + 9;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (auto &c : a) cin >> c;
  for (auto &c : b) cin >> c;
  int target1 = *min_element(a.begin(), a.end());
  int target2 = *min_element(b.begin(), b.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += max(a[i] - target1, b[i] - target2);
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
