#include <bits/stdc++.h>
using namespace std;
long long int num_moves(vector<int> &a, vector<int> &o) {
  int sz = a.size();
  int min_a = *min_element(a.begin(), a.end());
  int min_o = *min_element(o.begin(), o.end());
  long long int ans = 0;
  for (int i = 0; i < sz; i++) {
    int ele1 = a[i] - min_a;
    int ele2 = o[i] - min_o;
    ans += max(ele1, ele2);
  }
  return ans;
}
int main() {
  int num_cases;
  cin >> num_cases;
  vector<int> apples;
  vector<int> oranges;
  for (int i = 0; i < num_cases; i++) {
    int num_eles;
    cin >> num_eles;
    int tmp;
    apples.clear();
    oranges.clear();
    for (int j = 0; j < num_eles; j++) {
      cin >> tmp;
      apples.push_back(tmp);
    }
    for (int j = 0; j < num_eles; j++) {
      cin >> tmp;
      oranges.push_back(tmp);
    }
    long long int ans = num_moves(apples, oranges);
    cout << ans << endl;
  }
  return 0;
}
