#include <bits/stdc++.h>
typedef struct Pair {
  int l;
  int r;
} pair;
int cmp_r(const void *a, const void *b) {
  return ((pair *)a)->r - ((pair *)b)->r;
}
int cmp_l(const void *a, const void *b) {
  return ((pair *)a)->l - ((pair *)b)->l;
}
int main() {
  int n, m;
  scanf("%d", &n);
  pair chess[n];
  int i;
  int distance = 0;
  for (i = 0; i < n; i++) {
    scanf("%d %d", &(chess[i].l), &(chess[i].r));
  }
  scanf("%d", &m);
  pair prog[m];
  for (i = 0; i < m; i++) {
    scanf("%d %d", &(prog[i].l), &(prog[i].r));
  }
  qsort(chess, n, sizeof(pair), cmp_r);
  qsort(prog, m, sizeof(pair), cmp_l);
  if (prog[m - 1].l - chess[0].r > 0) {
    distance = prog[m - 1].l - chess[0].r;
  }
  qsort(chess, n, sizeof(pair), cmp_l);
  qsort(prog, m, sizeof(pair), cmp_r);
  if (chess[n - 1].l - prog[0].r > distance) {
    distance = chess[n - 1].l - prog[0].r;
  }
  printf("%d\n", distance);
  return 0;
}
