#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    long long a[60], b[60];
    long long mina = 0, minb = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (i == 0 || a[i] < mina) {
        mina = a[i];
      }
    }
    for (int i = 0; i < n; ++i) {
      cin >> b[i];
      if (i == 0 || b[i] < minb) {
        minb = b[i];
      }
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
      ans += max(a[i] - mina, b[i] - minb);
    }
    cout << ans << endl;
  }
  return 0;
}
