#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, mx = 0, my = (1 << 31) - 1, m2x = 0, m2y = (1 << 31) - 1, a, b;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    mx = max(mx, a);
    my = min(my, b);
  }
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    m2x = max(m2x, a);
    m2y = min(m2y, b);
  }
  int res = 0;
  if (m2x > my) res = max(res, m2x - my);
  if (mx > m2y) res = max(res, mx - m2y);
  printf("%d\n", res);
  return 0;
}
