#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> A(n);
    vector<long long int> B(n);
    long long int minA = INT_MAX;
    long long int minB = INT_MAX;
    for (long long int i = 0; i < n; i++) {
      cin >> A[i];
      minA = min(minA, A[i]);
    }
    for (long long int i = 0; i < n; i++) {
      cin >> B[i];
      minB = min(minB, B[i]);
    }
    long long int ans = 0, diff1, diff2;
    for (long long int i = 0; i < n; i++) {
      diff1 = A[i] - minA;
      diff2 = B[i] - minB;
      ans += max(diff1, diff2);
    }
    cout << ans << "\n";
  }
  return 0;
}
