#include <bits/stdc++.h>
using namespace std;
long long int minm(vector<int> a) {
  long long int min_el = LONG_MAX;
  for (auto i : a) {
    min_el = (min_el < i) ? min_el : i;
  }
  return min_el;
}
void solve() {
  long long int n, x, ans = 0, mina, minb, diffa, diffb, mindiff;
  vector<int> a, b;
  cin >> n;
  for (int i = 0; i < (n); i++) {
    cin >> x;
    a.push_back(x);
  }
  for (int i = 0; i < (n); i++) {
    cin >> x;
    b.push_back(x);
  }
  mina = minm(a);
  minb = minm(b);
  for (int i = 0; i < (n); i++) {
    if (a[i] != mina and b[i] != minb) {
      diffa = a[i] - mina;
      diffb = b[i] - minb;
      mindiff = (diffa < diffb) ? diffa : diffb;
      ans += mindiff;
      a[i] -= mindiff;
      b[i] -= mindiff;
    }
    if (a[i] != mina) {
      ans += a[i] - mina;
    }
    if (b[i] != minb) {
      ans += b[i] - minb;
    }
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
