#include <bits/stdc++.h>
using namespace std;
const int N = 57;
int n, t;
long long ans;
int a[N], b[N], cnt[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    ans = 1e11 + 7;
    int x = *min_element(a, a + n), y = *min_element(b, b + n);
    memset(cnt, 0, sizeof cnt);
    for (int i = 0; i < n; ++i) cnt[i] = abs(a[i] - x);
    for (int i = 0; i < n; ++i) cnt[i] = max(cnt[i], abs(b[i] - y));
    long long res = 0;
    for (int i = 0; i < n; ++i) res += cnt[i];
    ans = min(ans, res);
    cout << ans << '\n';
  }
  return 0;
}
