#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long n, i, j, q, r, g, m, e, h, tt, s, l, z, x, y, x1, y1, k, t, p;
  double sg, fg, d, sig, nd;
  string a, b, c;
  cin >> n;
  long long ans = 0;
  x = x1 = 0;
  y = y1 = 10e9 + 1;
  for (i = 0; i < n; i++) {
    cin >> j >> k;
    x = max(j, x);
    y = min(k, y);
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> j >> k;
    x1 = max(j, x1);
    y1 = min(k, y1);
  }
  l = max(x - y1, x1 - y);
  if (l < 0) l = 0;
  cout << l << endl;
  return 0;
}
