#include <bits/stdc++.h>
using namespace std;
int tc;
int main() {
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    int a[n], mna = INT_MAX, mnb = INT_MAX, b[n];
    for (int i = 0; i < n; i++) cin >> a[i], mna = min(mna, a[i]);
    for (int i = 0; i < n; i++) cin >> b[i], mnb = min(mnb, b[i]);
    long long int ans = 0;
    for (int i = 0; i < n; i++) {
      ans += max((a[i] - mna), (b[i] - mnb));
    }
    cout << ans << "\n";
  }
  return 0;
}
