#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n], b[n];
    vector<long long> v1, v2;
    long long mna = 9999999999, mnb = 9999999999, ans = 0;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      mna = min(mna, a[i]);
    }
    for (long long i = 0; i < n; i++) {
      cin >> b[i];
      mnb = min(mnb, b[i]);
    }
    for (long long i = 0; i < n; i++) {
      v1.push_back(abs(mna - a[i]));
      v2.push_back(abs(mnb - b[i]));
    }
    for (long long i = 0; i < n; i++) {
      ans += max(v1[i], v2[i]);
    }
    cout << ans << endl;
  }
}
