#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18L + 5;
const int inf = 1e9 + 5;
struct comp {
  bool operator()(pair<int, int> p1, pair<int, int> p2) {
    if (p1.first < p2.first) return false;
    if (p2.first < p1.first) return true;
    return p1.second < p2.second;
  };
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test = 1;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    long long a[n], b[n];
    long long min_a = INF, min_b = INF;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      min_a = min(a[i], min_a);
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      min_b = min(b[i], min_b);
    }
    long long res = 0;
    for (int i = 0; i < n; i++) {
      res += max(a[i] - min_a, b[i] - min_b);
    }
    cout << res << endl;
  }
  return 0;
}
