#include <bits/stdc++.h>
using namespace std;
int n, a[1003], b[1003], vis[1003][1003];
vector<int> f[1003];
vector<pair<int, int> > res;
void solve() {
  cin >> n;
  int arr[n], brr[n], min1 = INT_MAX, min2 = INT_MAX;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    min1 = min(min1, arr[i]);
  }
  for (int i = 0; i < n; i++) {
    cin >> brr[i];
    min2 = min(min2, brr[i]);
  }
  for (int i = 0; i < n; i++) {
    int diff1 = arr[i] - min1;
    int diff2 = brr[i] - min2;
    ans += max(diff1, diff2);
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
