#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int w = 0; w < t; w++) {
    int n;
    long long int total = 0;
    cin >> n;
    long long int a[n], b[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    long long int *min1 = min_element(a, a + n);
    long long int *min2 = min_element(b, b + n);
    for (int i = 0; i < n; i++) {
      int temp1 = a[i] - (*min1);
      int temp2 = b[i] - (*min2);
      if (temp1 > temp2) {
        total += temp1;
      } else {
        total += temp2;
      }
    }
    cout << total << endl;
  }
}
