#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int minxiangqi = 0, maxxiangqi = 1000000001;
  int minchengxu = 0, maxchengxu = 1000000001;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a > minxiangqi) minxiangqi = a;
    if (b < maxxiangqi) maxxiangqi = b;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    if (x > minchengxu) minchengxu = x;
    if (y < maxchengxu) maxchengxu = y;
  }
  int chazhi = max(minxiangqi - maxchengxu, minchengxu - maxxiangqi);
  if (chazhi > 0)
    cout << chazhi << '\n';
  else
    cout << 0 << '\n';
  return 0;
}
