#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
void solve() {
  long long int mia = INT_MAX;
  long long int mib = INT_MAX;
  long long int n, x = 0, y = 0;
  long long int ans = 0;
  cin >> n;
  long long int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (mia > a[i]) {
      mia = a[i];
      x = i;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    if (mib > b[i]) {
      mib = b[i];
      y = i;
    }
  }
  ans = b[x] - mib;
  ans += a[y] - mia;
  for (int i = 0; i < n; i++) {
    if (i == x || i == y) continue;
    long long int aa = a[i] - mia;
    long long int bb = b[i] - mib;
    long long int temp = min(aa, bb);
    ans += temp;
    if (temp == aa) swap(aa, bb);
    ans += (aa - temp);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
