#include <bits/stdc++.h>
using namespace std;
int a[51], b[51];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    int am = 1e9, bm = 1e9;
    for (int i = 1; i <= n; i++) {
      am = min(am, a[i]);
      bm = min(bm, b[i]);
    }
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      int x = a[i] - am;
      int y = b[i] - bm;
      ans += min(x, y);
      ans += abs(x - y);
    }
    cout << ans << '\n';
  }
}
