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