#include <bits/stdc++.h>
using namespace std;
const int N = 200;
const int mod = 1e9 + 7;
long long a[N], b[N];
int main() {
  int _;
  scanf("%d", &_);
  while (_--) {
    long long n, a_min = 1e9 + 7, b_min = 1e9 + 7;
    scanf("%lld", &n);
    for (long long i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
      a_min = min(a_min, a[i]);
    }
    for (long long i = 0; i < n; i++) {
      scanf("%lld", &b[i]);
      b_min = min(b_min, b[i]);
    }
    long long sum = 0, x, y;
    for (long long i = 0; i < n; i++) {
      x = a[i] - a_min, y = b[i] - b_min;
      sum += min(x, y);
      sum += max(x, y) - min(x, y);
    }
    printf("%lld\n", sum);
  }
}
