#include <bits/stdc++.h>
using namespace std;
int const N = 50 + 10;
int t, n, a[N], b[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    int mna = 1e9 + 10, mnb = 1e9 + 10;
    long long ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mna = min(mna, a[i]);
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      mnb = min(mnb, b[i]);
    }
    for (int i = 0; i < n; i++) {
      int da = a[i] - mna, db = b[i] - mnb;
      ans += da + db - min(da, db);
    }
    cout << ans << '\n';
  }
}
