#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
void READ() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    long long mina, minb;
    mina = minb = LLONG_MAX;
    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]);
    }
    long long moves = 0LL;
    for (int i = 0; i < n; ++i) {
      long long moveA, moveB;
      moveA = moveB = 0LL;
      if (a[i] > mina) {
        moveA = a[i] - mina;
      }
      if (b[i] > minb) {
        moveB = b[i] - minb;
      }
      moves += min(moveA, moveB) + llabs(moveA - moveB);
    }
    cout << moves << endl;
  }
  return 0;
}
