#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    long long int a[n];
    long long int b[n];
    long long int mini1 = 1000000000, mini2 = 1000000000;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mini1 = min(mini1, a[i]);
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      mini2 = min(mini2, b[i]);
    }
    long long int ans = 0;
    for (int i = 0; i < n; i++) {
      a[i] = a[i] - mini1;
      b[i] = b[i] - mini2;
      ans += max(a[i], b[i]);
    }
    cout << ans << endl;
  }
}
