#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  cin >> T;
  for (long long t = 0; t < T; ++t) {
    long long n;
    cin >> n;
    long long a[n], b[n];
    long long x[n], y[n];
    for (long long i = 0; i < n; ++i) {
      cin >> a[i];
      x[i] = a[i];
    }
    for (long long i = 0; i < n; ++i) {
      cin >> b[i];
      y[i] = b[i];
    }
    sort(x, x + n);
    sort(y, y + n);
    long long mia = x[0], mib = y[0];
    long long moves = 0;
    for (long long i = 0; i < n; ++i) {
      moves += max(abs(mia - a[i]), abs(mib - b[i]));
    }
    cout << moves << "\n";
  }
  return 0;
}
