#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int testCase;
  cin >> testCase;
  while (testCase--) {
    int gifts;
    cin >> gifts;
    int candy[gifts], orange[gifts];
    int candyStan = INT_MAX, orangeStan = INT_MAX;
    for (int index = 0; index < gifts; ++index) {
      cin >> candy[index];
      candyStan = min(candyStan, candy[index]);
    }
    for (int index = 0; index < gifts; ++index) {
      cin >> orange[index];
      orangeStan = min(orangeStan, orange[index]);
    }
    unsigned long long count = 0;
    for (int index = 0; index < gifts; ++index)
      count += max(candy[index] - candyStan, orange[index] - orangeStan);
    cout << count << endl;
  }
  return 0;
}
