#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i, j, k, l;
    cin >> n;
    long long int a[n + 2], b[n + 2];
    k = 1e18, l = 1e18;
    for (long long int i = 0; i <= n - 1; i++) cin >> a[i], k = min(k, a[i]);
    for (long long int i = 0; i <= n - 1; i++) cin >> b[i], l = min(l, b[i]);
    long long int ans = 0;
    for (long long int i = 0; i <= n - 1; i++) {
      long long int xx, yy;
      xx = (a[i] - k);
      yy = (b[i] - l);
      j = min(xx, yy);
      ans += (xx + yy - j);
    }
    cout << ans << '\n';
  }
  return 0;
}
