#include <bits/stdc++.h>
using namespace std;
int main() {
  long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n], b[n], moves = 0;
    long long aminimum = 2147483657, bminimum = 2147483657;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      aminimum = min(aminimum, a[i]);
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      bminimum = min(bminimum, b[i]);
    }
    for (int i = 0; i < n; i++) {
      moves += max((a[i] - aminimum), (b[i] - bminimum));
    }
    cout << moves << endl;
  }
}
