#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  long long minrn = 1000000000000000007ll, maxln = 0,
            minrm = 1000000000000000007ll, maxlm = 0;
  pair<long long, long long> p1, p2, p3, p4;
  cin >> n;
  long long l, r;
  for (long long i = 0; i < n; i++) {
    cin >> l >> r;
    if (minrn > r) {
      minrn = r;
      p1 = make_pair(l, r);
    }
    if (maxln < l) {
      maxln = l;
      p2 = make_pair(l, r);
    }
  }
  cin >> m;
  for (long long i = 0; i < m; i++) {
    cin >> l >> r;
    if (minrm > r) {
      minrm = r;
      p3 = make_pair(l, r);
    }
    if (maxlm < l) {
      maxlm = l;
      p4 = make_pair(l, r);
    }
  }
  long long ans = 0;
  if (p4.first > p1.second) ans = max(ans, p4.first - p1.second);
  if (p2.first > p3.second) ans = max(ans, p2.first - p3.second);
  cout << ans << "\n";
}
