#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int a[n], b[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    long long int ans = 0;
    long long int mina = *min_element(a, a + n);
    long long int minb = *min_element(b, b + n);
    for (int i = 0; i < n; i++) {
      ans =
          ans + ((a[i] - mina) > (b[i] - minb) ? (a[i] - mina) : (b[i] - minb));
    }
    cout << ans << endl;
  }
}
