#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int T;
  cin >> T;
  while (T--) {
    long long int n;
    cin >> n;
    long long int a[n], b[n];
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (long long int i = 0; i < n; i++) {
      cin >> b[i];
    }
    long long int count = 0;
    long long int firstmin = *min_element(a, a + n);
    long long int secondmin = *min_element(b, b + n);
    for (int i = 0; i < n; i++) {
      count += max((a[i] - firstmin), (b[i] - secondmin));
    }
    cout << count << "\n";
  }
  return 0;
}
