#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t-- != 0) {
    long long int n;
    cin >> n;
    long long int c[n];
    long long int b[n];
    for (long long int i = 0; i < n; i++) cin >> c[i];
    for (long long int i = 0; i < n; i++) cin >> b[i];
    if (n == 1) {
      cout << "0" << endl;
      continue;
    }
    long long int minC = INT_MAX, minB = INT_MAX;
    for (long long int i = 0; i < n; i++) {
      if (c[i] < minC) minC = c[i];
      if (b[i] < minB) minB = b[i];
    }
    long long int nMoves = 0;
    for (long long int i = 0; i < n; i++) {
      if (c[i] > minC && b[i] > minB) {
        nMoves += min(c[i] - minC, b[i] - minB);
        nMoves += abs((c[i] - minC) - (b[i] - minB));
      } else if (b[i] > minB) {
        nMoves += b[i] - minB;
      } else if (c[i] > minC) {
        nMoves += c[i] - minC;
      }
    }
    cout << nMoves << endl;
  }
  return 0;
}
