#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n, 0), b(n, 0);
  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 a_min = *min_element(a.begin(), a.end());
  long long int b_min = *min_element(b.begin(), b.end());
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    ans += max((a[i] - a_min), (b[i] - b_min));
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  long long int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
