#include <bits/stdc++.h>
using namespace std;
const long long infll = powl(2, 62) - 1;
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long maxC = 0, minC = infll;
  long long maxP = 0, minP = infll;
  while (n--) {
    long long a, b;
    cin >> a >> b;
    if (a > maxC) maxC = a;
    if (b < minC) minC = b;
  }
  cin >> n;
  while (n--) {
    long long a, b;
    cin >> a >> b;
    if (a > maxP) maxP = a;
    if (b < minP) minP = b;
  }
  long long ans = max(maxP - minC, maxC - minP);
  cout << max(ans, 0ll) << endl;
  return 0;
}
