#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long int t, n, x, i, j, count{0};
  long long int cn;
  cin >> cn;
  while (cn--) {
    count = 0;
    cin >> n;
    long long int a[n], b[n];
    long long int min1 = INT_MAX;
    long long int min2 = INT_MAX;
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] < min1) min1 = a[i];
    }
    for (long long int i = 0; i < n; i++) {
      cin >> b[i];
      if (b[i] < min2) min2 = b[i];
    }
    for (long long int i = 0; i < n; i++) {
      if (a[i] > min1 && b[i] > min2) {
        if ((a[i] - min1) < (b[i] - min2)) {
          count = count + (b[i] - (a[i] - min1)) - min2 + (a[i] - min1);
        } else {
          count = count + (a[i] - (b[i] - min2)) - min1 + (b[i] - min2);
        }
      } else if (a[i] > min1) {
        count = count + (a[i] - min1);
      } else if (b[i] > min2) {
        count = count + (b[i] - min2);
      }
    }
    cout << count << endl;
  }
  return 0;
}
