#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> a(n), b(n);
    for (auto &it : a) cin >> it;
    for (auto &it : b) cin >> it;
    int ma = *min_element(a.begin(), a.end());
    int mb = *min_element(b.begin(), b.end());
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
      ans += max(a[i] - ma, b[i] - mb);
    }
    cout << ans << endl;
  }
}
