#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], o[n];
    int minapple = INT_MAX, minorange = INT_MAX;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      minapple = min(minapple, a[i]);
    }
    for (int i = 0; i < n; i++) {
      cin >> o[i];
      minorange = min(minorange, o[i]);
    }
    long long moves = 0;
    for (int i = 0; i < n; i++) {
      a[i] -= minapple;
      o[i] -= minorange;
      moves += min(a[i], o[i]);
      moves += (max(a[i], o[i]) - min(a[i], o[i]));
    }
    cout << moves << '\n';
    ;
  }
}
