#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    long long x = *min_element(a, a + n);
    long long y = *min_element(b, b + n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      a[i] = abs(a[i] - x);
      b[i] = abs(b[i] - y);
      sum += max(a[i], b[i]);
    }
    cout << sum << "\n";
  }
}
