#include <bits/stdc++.h>
using namespace std;
int a[200010][2], b[200010][2];
int main() {
  int i, j, n, m, l1, l2, r1, r2, ans;
  while (~scanf("%d", &n)) {
    l1 = 0;
    r1 = 0x3f3f3f3f;
    for (i = 0; i < n; i++) {
      scanf("%d%d", &a[i][0], &a[i][1]);
      if (a[i][0] > l1) l1 = a[i][0];
      if (a[i][1] < r1) r1 = a[i][1];
    }
    scanf("%d", &m);
    l2 = 0;
    r2 = 0x3f3f3f3f;
    for (i = 0; i < m; i++) {
      scanf("%d%d", &b[i][0], &b[i][1]);
      if (b[i][0] > l2) l2 = b[i][0];
      if (b[i][1] < r2) r2 = b[i][1];
    }
    ans = max(l1 - r2, l2 - r1);
    if (ans < 0)
      printf("0\n");
    else
      printf("%d\n", ans);
  }
  return 0;
}
