#include <bits/stdc++.h>
using namespace std;
string numtostr(long long n) {
  ostringstream str1;
  str1 << n;
  return str1.str();
}
long long strtonum(string s) {
  long long x;
  stringstream str1(s);
  str1 >> x;
  return x;
}
long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
  long long gcd = GCD(a, b);
  return (a / gcd) * b;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v1, v2;
    long long mina = LLONG_MAX;
    long long minb = LLONG_MAX;
    for (long long i = 0; i <= n - 1; i++) {
      long long a;
      cin >> a;
      v1.push_back(a);
      mina = min(mina, a);
    }
    for (long long i = 0; i <= n - 1; i++) {
      long long a;
      cin >> a;
      v2.push_back(a);
      minb = min(minb, a);
    }
    long long sum = 0;
    for (long long i = 0; i <= n - 1; i++) {
      long long baki1 = v1[i] - mina;
      long long baki2 = v2[i] - minb;
      long long both = min(baki1, baki2);
      sum += both + (baki1 - both) + (baki2 - both);
    }
    cout << sum << endl;
  }
  return 0;
}
