#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<long long int> a(n), b(n);
    long long int mina = INT_MAX, minb = INT_MAX;
    long long int cnt = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mina = min(mina, a[i]);
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      minb = min(minb, b[i]);
    }
    for (int i = 0; i < n; i++) {
      if (a[i] > mina && b[i] > minb) {
        long long int diff1 = a[i] - mina;
        long long int diff2 = b[i] - minb;
        long long int mindiff = min(diff1, diff2);
        cnt += mindiff;
        a[i] = a[i] - mindiff;
        b[i] = b[i] - mindiff;
      }
    }
    for (int i = 0; i < n; i++) {
      cnt += abs(a[i] - mina);
    }
    for (int i = 0; i < n; i++) cnt += abs(b[i] - minb);
    cout << cnt << endl;
  }
  return 0;
}
