#include <bits/stdc++.h>
using namespace std;
long long int large(long long int a, long long int b) { return a > b ? a : b; }
void solve() {
  int n;
  cin >> n;
  long long int ans = 0;
  vector<long long int> a(n, 0);
  vector<long long int> b(n, 0);
  long long int sa = INT_MAX;
  long long int sb = INT_MAX;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < sa) sa = a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (b[i] < sb) sb = b[i];
  }
  for (int i = 0; i < n; i++) {
    if (b[i] > sb && a[i] > sa) {
      ans += large(b[i] - sb, a[i] - sa);
    } else if (b[i] > sb) {
      ans += b[i] - sb;
    } else if (a[i] > sa) {
      ans += a[i] - sa;
    }
  }
  cout << ans << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
