#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > vec;
void solve() {
  int n;
  scanf("%d", &n);
  vec.resize(n);
  long long res = 0, mn1 = 1e9, mn2 = 1e9;
  for (auto &x : vec) {
    scanf("%lld", &x.first);
    mn1 = min(mn1, x.first);
  }
  for (auto &x : vec) {
    scanf("%lld", &x.second);
    mn2 = min(mn2, x.second);
  }
  for (auto &x : vec) {
    res += max(x.first - mn1, x.second - mn2);
  }
  printf("%lld\n", res);
}
int main() {
  int Test = 1;
  scanf("%d", &Test);
  while (Test--) {
    solve();
  }
  return 0;
}
