#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long candies[n];
    long long oranges[n];
    for (int i = 0; i < n; i++) {
      cin >> candies[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> oranges[i];
    }
    long long mc = INT_MAX;
    long long oc = INT_MAX;
    for (int i = 0; i < n; i++) {
      if (candies[i] < mc) {
        mc = candies[i];
      }
    }
    for (int j = 0; j < n; j++) {
      if (oranges[j] < oc) {
        oc = oranges[j];
      }
    }
    for (int i = 0; i < n; i++) {
      candies[i] = candies[i] - mc;
    }
    for (int i = 0; i < n; i++) {
      oranges[i] = oranges[i] - oc;
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      long long m = max(candies[i], oranges[i]);
      ans = ans + m;
    }
    cout << ans << endl;
  }
}
