#include <bits/stdc++.h>
int main() {
  long long int k1 = 0, k2 = 0, n, m, i, j, k, l, minn = 0, minm = 0,
                maxn = 10000000000, maxm = 10000000000;
  scanf("%lld", &n);
  while (n--) {
    scanf("%lld %lld", &i, &j);
    if (i >= minn) minn = i;
    if (j <= maxn) maxn = j;
  }
  scanf("%lld", &m);
  while (m--) {
    scanf("%lld %lld", &i, &j);
    if (i >= minm) minm = i;
    if (j <= maxm) maxm = j;
  }
  k1 = (minn - maxm);
  k2 = (minm - maxn);
  if (k1 <= 0) k1 = 0;
  if (k2 <= 0) k2 = 0;
  if (k1 >= k2)
    printf("%lld\n", k1);
  else
    printf("%lld\n", k2);
  return 0;
}
