#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    unsigned long long int mino = LONG_MAX;
    unsigned long long int minc = LONG_MAX;
    unsigned long long int ans = 0;
    unsigned long long int n;
    cin >> n;
    unsigned long long int o[n], c[n];
    for (unsigned long long int i = 0; i < n; i++) {
      unsigned long long int ora;
      cin >> ora;
      o[i] = ora;
      if (ora < mino) {
        mino = ora;
      }
    }
    for (unsigned long long int i = 0; i < n; i++) {
      unsigned long long int ca;
      cin >> ca;
      c[i] = ca;
      if (ca < minc) {
        minc = ca;
      }
    }
    for (unsigned long long int i = 0; i < n; i++) {
      unsigned long long int w = min(o[i] - mino, c[i] - minc);
      ans = ans + w;
      o[i] = o[i] - w;
      c[i] = c[i] - w;
      if (o[i] == mino) {
        ans = ans + c[i] - minc;
      } else {
        ans = ans + o[i] - mino;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
