#include <bits/stdc++.h>
using namespace std;
int main() {
std:
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    long long total = 0;
    int maxa, maxb;
    cin >> n;
    long long mina = INT_MAX, minb = INT_MAX;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (mina > a[i]) {
        mina = a[i];
      }
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      if (minb > b[i]) {
        minb = b[i];
      }
    }
    for (int i = 0; i < n; i++) {
      maxa = a[i] - mina;
      maxb = b[i] - minb;
      if (maxa > maxb) {
        total += maxa;
      } else {
        total += maxb;
      }
    }
    cout << total << "\n";
  }
  return 0;
}
