#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, m, d, c, x, sum = 0, mn = 10000000000, mx = 10000000000;
    cin >> n;
    long long int a[n];
    long long int b[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      mn = min(mn, a[i]);
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      mx = min(mx, b[i]);
    }
    for (int i = 0; i < n; i++) {
      a[i] = abs(a[i] - mn);
      b[i] = abs(b[i] - mx);
    }
    for (int i = 0; i < n; i++) {
      d = max(a[i], b[i]);
      sum += d;
    }
    cout << sum << endl;
  }
}
