#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<long long> b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    long long m1 = INT_MAX;
    long long m2 = INT_MAX;
    for (int i = 0; i < n; i++) {
      if (a[i] < m1) m1 = a[i];
      if (b[i] < m2) m2 = b[i];
    }
    long long k = 0;
    for (int i = 0; i < n; i++) {
      long long z = ((a[i] - m1) >= (b[i] - m2)) ? (a[i] - m1) : (b[i] - m2);
      k += z;
    }
    cout << k << endl;
  }
  return 0;
}
