#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> a(n);
    vector<long long int> b(n);
    for (long long int i = 0; i < n; i++) cin >> a[i];
    for (long long int i = 0; i < n; i++) cin >> b[i];
    long long int minic = *min_element(a.begin(), a.end());
    long long int minio = *min_element(b.begin(), b.end());
    long long int move = 0;
    for (long long int i = 0; i < n; i++) {
      if (a[i] != minic && b[i] != minio) {
        long long int f = abs(a[i] - minic);
        long long int s = abs(b[i] - minio);
        if (f >= s)
          move += f;
        else
          move += s;
      } else if (a[i] != minic && b[i] == minio)
        move += abs(a[i] - minic);
      else if (b[i] != minio && a[i] == minic)
        move += abs(b[i] - minio);
      else
        continue;
    }
    cout << move << endl;
  }
}
