#include <bits/stdc++.h>
using namespace std;
double mod(double a) {
  if (a < 0) return -1 * a;
  return a;
}
bool prime[100000000 + 1];
void SieveOfEratosthenes() {
  long long int n = 100000000;
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1, u, j;
  cin >> t;
  for (u = 1; u <= t; u++) {
    long long int m, n, i, j, z, a = INT_MAX, b = INT_MAX, x, y, k, p = 0,
                                 q = 0, p1 = INT_MAX, p2 = 0, p3 = 0, ans = 0,
                                 l, r, index = -1;
    cin >> n;
    long long int A[n], B[n];
    for (i = 0; i < n; i++) {
      cin >> A[i];
      a = min(a, A[i]);
    }
    for (i = 0; i < n; i++) {
      cin >> B[i];
      b = min(b, B[i]);
    }
    for (i = 0; i < n; i++) {
      p = p + max(A[i] - a, B[i] - b);
    }
    cout << p << endl;
  }
}
