#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, r1min = INT_MAX, r2min = INT_MAX, l1max = 0, l2max = 0, l, r;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &l, &r);
    r1min = min(r1min, r);
    l1max = max(l1max, l);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &l, &r);
    r2min = min(r2min, r);
    l2max = max(l2max, l);
  }
  printf("%d\n", max(l1max - r2min, max(0, l2max - r1min)));
  return 0;
}
