#include <bits/stdc++.h>
using namespace std;
using lli = int64_t;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin >> T;
  for (int t = 1; t <= T; t++) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    int min_a = INT_MAX, min_b = INT_MAX;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      min_a = min(min_a, a[i]);
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      min_b = min(min_b, b[i]);
    }
    lli moves = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] > min_a and b[i] > min_b) {
        int x = min(abs(min_a - a[i]), abs(min_b - b[i]));
        moves += x;
        a[i] -= x, b[i] -= x;
      }
    }
    for (int i = 0; i < n; i++) {
      if (a[i] > min_a) {
        moves += (a[i] - min_a);
      }
      if (b[i] > min_b) {
        moves += (b[i] - min_b);
      }
    }
    cout << moves << "\n";
  }
}
