#include <bits/stdc++.h>
using namespace std;
long long a[55], b[55];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    long long a_mini = *min_element(a, a + n);
    long long b_mini = *min_element(b, b + n);
    long long moves_mini = 0;
    for (int i = 0; i < n; i++) {
      long long a_surplus = a[i] - a_mini;
      long long b_surplus = b[i] - b_mini;
      moves_mini += a_surplus + b_surplus - min(a_surplus, b_surplus);
    }
    cout << moves_mini << "\n";
  }
  return 0;
}
