#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  long long int mina, minb, moves = 0;
  cin >> n;
  vector<long long int> a(n);
  vector<long long int> b(n);
  cin >> a[0];
  mina = a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    if (mina > a[i]) mina = a[i];
  }
  cin >> b[0];
  minb = b[0];
  for (int i = 1; i < n; i++) {
    cin >> b[i];
    if (minb > b[i]) minb = b[i];
  }
  for (int i = 0; i < n; i++) {
    moves += max(a[i] - mina, b[i] - minb);
  }
  cout << moves;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}
