#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, a[55], b[55], i, amin, bmin;
  long long int sum;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    amin = 0x3f3f3f3f;
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      if (amin > a[i]) amin = a[i];
    }
    bmin = 0x3f3f3f3f;
    for (i = 0; i < n; i++) {
      scanf("%d", &b[i]);
      if (bmin > b[i]) bmin = b[i];
    }
    sum = 0;
    for (i = 0; i < n; i++) {
      int x = a[i] - amin;
      int y = b[i] - bmin;
      sum += max(x, y);
    }
    printf("%lld\n", sum);
  }
  return 0;
}
