#include <bits/stdc++.h>
using namespace std;
const int need = 200005;
inline void in_(int &d) {
  char t = getchar();
  while (t < '0' || t > '9') t = getchar();
  for (d = 0; t >= '0' && t <= '9'; t = getchar())
    d = (d << 3) + (d << 1) - '0' + t;
}
struct fy {
  int a, b;
};
fy a[need], b[need];
int main() {
  int n, m;
  cin >> n;
  int nl = 0, nr = 1e9;
  int ml = 0, mr = 1e9;
  int a, b;
  for (int i = 1; i <= n; i++) {
    in_(a), in_(b);
    nl = max(nl, a);
    nr = min(nr, b);
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    in_(a), in_(b);
    ml = max(ml, a);
    mr = min(mr, b);
  }
  int ans = max(ml - nr, nl - mr);
  cout << (ans < 0 ? 0 : ans);
}
