#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<long long> a(n);
    vector<long long> b(n);
    long long ma = LONG_LONG_MAX, mb = LONG_LONG_MAX;
    for (auto &i : a) {
      cin >> i;
      ma = min(ma, i);
    }
    for (auto &i : b) {
      cin >> i;
      mb = min(mb, i);
    }
    long long c = 0;
    for (int i = 0; i < n; i++) {
      c += max(a[i] - ma, b[i] - mb);
    }
    cout << c << endl;
  }
}
