#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, amin, bmin;
  cin >> t;
  while (t--) {
    long long int answer = 0;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int j = 0; j < n; j++) {
      cin >> b[j];
    }
    n = sizeof(a) / sizeof(a[0]);
    amin = *min_element(a, a + n);
    bmin = *min_element(b, b + n);
    for (int x = 0; x < n; x++) {
      answer += max(a[x] - amin, b[x] - bmin);
    }
    cout << answer << endl;
  }
}
