#include <bits/stdc++.h>
void solve() {
  int n;
  std::cin >> n;
  std::vector<long long> arr1(n), arr2(n);
  for (int i = 0; i < n; i++) std::cin >> arr1[i];
  for (int i = 0; i < n; i++) std::cin >> arr2[i];
  long long minA = 99999999999999;
  long long minB = 99999999999999;
  for (int i = 0; i < n; i++) {
    if (minA > arr1[i]) minA = arr1[i];
    if (minB > arr2[i]) minB = arr2[i];
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    long long res1 = arr1[i] - minA;
    long long res2 = arr2[i] - minB;
    if (res1 > res2)
      sum += res2;
    else
      sum += res1;
    sum += std::abs(res1 - res2);
  }
  std::cout << sum;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  int t;
  std::cin >> t;
  while (t--) {
    solve();
    std::cout << "\n";
  }
}
