#include <bits/stdc++.h>
const int mod = 1e9 + 7;
long long int power(long long int a, long long int b) {
  long long int r = 1;
  for (; b; b >>= 1) {
    if (b & 1) r = r * a % mod;
    a = a * a % mod;
  }
  return r;
}
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    int m1 = *min_element(a, a + n), m2 = *min_element(b, b + n);
    long long int ans = 0;
    for (int i = 0; i < n; i++) ans += max(abs(a[i] - m1), abs(b[i] - m2));
    cout << ans << '\n';
  }
  return 0;
}
