#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int a[n];
    long long int b[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    int mina = INT_MAX;
    int minb = INT_MAX;
    for (int i = 0; i < n; i++) {
      if (a[i] < mina) {
        mina = a[i];
      }
    }
    for (int i = 0; i < n; i++) {
      if (b[i] < minb) {
        minb = b[i];
      }
    }
    long long int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] > mina && b[i] > minb) {
        long long int z = min((b[i] - minb), (a[i] - mina));
        long long int y = max((b[i] - minb), (a[i] - mina));
        cnt = cnt + y;
      } else if (a[i] > mina) {
        cnt = cnt + a[i] - mina;
      } else if (b[i] > minb) {
        cnt = cnt + b[i] - minb;
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
