#include <bits/stdc++.h>
const int maxn = 55;
using namespace std;
int t, n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    int a[maxn] = {0}, b[maxn] = {0};
    int minia = 1 << 30, minib = 1 << 30;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      minia = min(minia, a[i]);
    }
    for (int i = 1; i <= n; i++) {
      cin >> b[i];
      minib = min(minib, b[i]);
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      ans += max(a[i] - minia, b[i] - minib);
    }
    cout << ans << endl;
  }
  return 0;
}
