#include <bits/stdc++.h>
using namespace std;
long long int Max(long long int a, long long int b) { return (a > b) ? a : b; }
void question() {
  long long int n;
  cin >> n;
  long long int a[n], b[n];
  cin >> a[0];
  int minA = a[0];
  for (long long int i = 1; i < n; i++) {
    cin >> a[i];
    if (a[i] < minA) minA = a[i];
  }
  cin >> b[0];
  int minB = b[0];
  for (long long int i = 1; i < n; i++) {
    cin >> b[i];
    if (b[i] < minB) minB = b[i];
  }
  long long int moves = 0;
  for (long long int i = 0; i < n; i++) {
    moves += Max(a[i] - minA, b[i] - minB);
  }
  cout << moves << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    question();
  }
}
