#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, n, i, j, x, y, z, c, d;
  cin >> t;
  for (i = 1; i <= t; i++) {
    cin >> n;
    x = 10e10;
    y = 10e10;
    z = 0;
    int a[n], b[n];
    for (j = 0; j < n; j++) {
      cin >> a[j];
      if (a[j] < x) x = a[j];
    }
    for (j = 0; j < n; j++) {
      cin >> b[j];
      if (b[j] < y) y = b[j];
    }
    for (j = 0; j < n; j++) {
      c = 0;
      d = 0;
      if (a[j] > x) c = 1;
      if (b[j] > y) d = 1;
      if (c == 1 && d == 1) {
        long long int k = max(a[j] - x, b[j] - y);
        z = z + k;
      } else if (c == 1 && d == 0)
        z = z + a[j] - x;
      else if (d == 1 && c == 0)
        z = z + b[j] - y;
    }
    cout << z << endl;
  }
}
