#include <bits/stdc++.h>
using namespace std;
int n, m, i, x, y, ans, nu = 1000000001, mu = 1000000001, nl = -1, ml = -1;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    nu = min(y, nu);
    nl = max(x, nl);
  }
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &x, &y);
    mu = min(y, mu);
    ml = max(x, ml);
  }
  cout << max(0, max(ml - nu, nl - mu)) << endl;
  return 0;
}
