#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
const int INF = 1e9;
long long a[51], b[51];
void solve() {
  long long n, l = INF, r = INF;
  long long ans = 0;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    l = min(a[i], l);
  }
  for (int i = 1; i <= n; ++i) {
    cin >> b[i];
    r = min(b[i], r);
  }
  for (int i = 1; i <= n; ++i) {
    int x = a[i] - l, y = b[i] - r;
    ans += max(x, y);
  }
  cout << ans;
}
int main() {
  int q;
  cin >> q;
  while (q--) {
    solve();
    cout << '\n';
  }
}
