#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t, n, a[55], b[55];
  cin >> t;
  while (t--) {
    long long sol = 0;
    int am = 1e9 + 7, bm = 1e9 + 7;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      am = min(am, a[i]);
    }
    for (int i = 0; i < n; ++i) {
      cin >> b[i];
      bm = min(bm, b[i]);
    }
    for (int i = 0; i < n; ++i) {
      sol += max(a[i] - am, b[i] - bm);
    }
    cout << sol << "\n";
  }
  return 0;
}
