#include <bits/stdc++.h>
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    long long arr1[n], arr2[n];
    int i;
    for (i = 0; i < n; i++) {
      scanf("%lld", &arr1[i]);
    }
    for (i = 0; i < n; i++) {
      scanf("%lld", &arr2[i]);
    }
    long long min1 = arr1[0], min2 = arr2[0];
    for (i = 0; i < n; i++) {
      if (arr1[i] < min1) min1 = arr1[i];
      if (arr2[i] < min2) min2 = arr2[i];
    }
    long long cnt1 = 0, cnt2 = 0;
    for (i = 0; i < n; i++) {
      cnt1 = cnt1 + (arr1[i] - min1);
      cnt2 = cnt2 + (arr2[i] - min2);
    }
    long long extra = 0, temp1, temp2;
    for (i = 0; i < n; i++) {
      temp1 = arr1[i] - min1;
      temp2 = arr2[i] - min2;
      if (temp1 <= temp2)
        extra = extra + temp1;
      else
        extra = extra + temp2;
    }
    long long answer = cnt1 + cnt2 - extra;
    printf("%lld\n", answer);
  }
  return 0;
}
