#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) {
  while (b > 0) {
    a = a % b;
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return a;
}
long long mcm(long long a, long long b) { return a * b / GCD(a, b); }
vector<int> KMP(string _text, string _pattern) {
  vector<int> matches;
  int* P = new int[1005];
  int n_pattern = _pattern.size();
  int n_text = _text.size();
  for (int i = 0; i < n_pattern; i++) P[i] = -1;
  for (int i = 0, j = -1; i < n_pattern;) {
    while (j > -1 && _pattern[i] != _pattern[j]) j = P[j];
    i++;
    j++;
    P[i] = j;
  }
  for (int i = 0, j = 0; i < n_text;) {
    while (j > -1 && _text[i] != _pattern[j]) j = P[j];
    i++;
    j++;
    if (j == n_pattern) {
      matches.push_back(i - n_pattern);
      j = P[j];
    }
  }
  return matches;
}
long long computeHash(string s) {
  const long long p = 31;
  const long long m = 1e9 + 9;
  long long hashValue = 0;
  long long pPow = 1;
  int ncharacter = s.size();
  char c;
  for (int i = 0; i < ncharacter; i++) {
    c = s[i];
    hashValue = (hashValue + (c - 'a' + 1) * pPow) % m;
    pPow = (pPow * p) % m;
  }
  return hashValue;
}
vector<vector<int> > group_identical_strings(vector<string> const& s) {
  int n = s.size();
  vector<pair<long long, int> > hashes(n);
  for (int i = 0; i < n; i++) hashes[i] = {computeHash(s[i]), i};
  sort(hashes.begin(), hashes.end());
  vector<vector<int> > groups;
  for (int i = 0; i < n; i++) {
    if (i == 0 || hashes[i].first != hashes[i - 1].first) {
      vector<int> aux;
      groups.push_back(aux);
    }
    groups.back().push_back(hashes[i].second);
  }
  return groups;
}
void solve() {
  int n;
  cin >> n;
  long long candy[n];
  long long oranges[n];
  long long maxCandy = 9223372036854775807, maxOrange = 9223372036854775807,
            moves = 0;
  for (int i = 0; i < (int)n; i++) {
    cin >> candy[i];
    maxCandy = min(maxCandy, candy[i]);
  }
  for (int i = 0; i < (int)n; i++) {
    cin >> oranges[i];
    maxOrange = min(maxOrange, oranges[i]);
  }
  for (int i = 0; i < (int)n; i++) {
    moves += max(candy[i] - maxCandy, oranges[i] - maxOrange);
  }
  cout << moves;
  cout << "\n";
  ;
}
int main() {
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int casos;
  cin >> casos;
  while (casos--) solve();
  return 0;
}
