#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x, i, y;
  long int cMax = 0, cMin = 99999999999;
  long int pMax = 0, pMin = 99999999999;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    if (cMax < x) cMax = x;
    if (cMin > y) cMin = y;
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    if (pMax < x) pMax = x;
    if (pMin > y) pMin = y;
  }
  int ans = max(cMax - pMin, pMax - cMin);
  if (ans < 0) ans = 0;
  cout << ans << endl;
  return 0;
}
