#include <bits/stdc++.h>
using namespace std;
vector<int> fac;
void solve() {
  long long int n, s, c = 0;
  cin >> n;
  vector<long long int> a, o;
  for (long long int i = 0; i < n; i++) {
    cin >> s;
    a.push_back(s);
  }
  for (long long int i = 0; i < n; i++) {
    cin >> s;
    o.push_back(s);
  }
  int a1 = *min_element(a.begin(), a.end());
  int o1 = *min_element(o.begin(), o.end());
  for (long long int i = 0; i < n; i++) {
    long long int e = a[i] - a1;
    long long int f = o[i] - o1;
    c += max(e, f);
  }
  cout << c << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
