#include <bits/stdc++.h>
using namespace std;
long long int n, min1, min2, q, a[100000], b[100000], s, p, k, t, c, l, i, j;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < n; i++) cin >> b[i];
    min1 = 10000000007, min2 = 10000000007;
    for (i = 0; i < n; i++) min1 = min(min1, a[i]);
    for (i = 0; i < n; i++) min2 = min(min2, b[i]);
    if (n == 1)
      cout << 0 << endl;
    else {
      for (i = 0; i < n; i++) {
        q = a[i] - min1;
        c = b[i] - min2;
        s = s + (max(q, c));
      }
      for (i = 0; i < n; i++) {
        k = k + (a[i] - min1) + (b[i] - min2);
      }
      cout << min(k, s) << endl;
    }
    k = 0, s = 0, q = 0, c = 0;
  }
}
