#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
int t, n;
long long a[55], b[55];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    long long ma = 1e9, mb = 1e9;
    memset(a, 0, sizeof a);
    memset(b, 0, sizeof b);
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &a[i]);
      ma = min(ma, a[i]);
    }
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &b[i]);
      mb = min(mb, b[i]);
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += max(a[i] - ma, b[i] - mb);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
