#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    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];
    }
    int minA = *min_element(a, a + n);
    int minB = *min_element(b, b + n);
    long long c = 0;
    for (int i = 0; i < n; i++) {
      c += max(a[i] - minA, b[i] - minB);
    }
    cout << c << endl;
  }
}
