#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);
  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 aa = INT_MAX, bb = INT_MAX;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      aa = min(aa, a[i]);
    }
    for (long long int i = 0; i < n; i++) {
      cin >> b[i];
      bb = min(bb, b[i]);
    }
    long long int i = 0, j = 0;
    long long int ans = 0;
    while (i < n) {
      if (aa != a[i] && a[i] - aa > b[i] - bb) {
        ans += a[i] - aa;
      } else if (bb != b[i]) {
        ans += b[i] - bb;
      }
      i++;
    }
    cout << ans << endl;
  }
  return 0;
}
