#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a, b;
  for (auto i = 0; i < n; i++) {
    long long int a1;
    cin >> a1;
    a.push_back(a1);
  }
  for (auto i = 0; i < n; i++) {
    long long int b1;
    cin >> b1;
    b.push_back(b1);
  }
  long long int count = 0;
  for (auto i = 0; i < n; i++) {
    count = count + a[i] - *min_element(a.begin(), a.end());
    count = count + b[i] - *min_element(b.begin(), b.end());
  }
  for (auto i = 0; i < n; i++) {
    if (a[i] != *min_element(a.begin(), a.end()) &&
        b[i] != *min_element(b.begin(), b.end())) {
      count = count - min(a[i] - *min_element(a.begin(), a.end()),
                          b[i] - *min_element(b.begin(), b.end()));
    }
  }
  cout << count << endl;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) solve();
}
