#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  int minc = *min_element(a, a + n);
  int mino = *min_element(b, b + n);
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    a[i] = a[i] - minc;
    b[i] = b[i] - mino;
    ans += max(a[i], b[i]);
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) solve();
  return 0;
}
