#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, R, l, r;
  int m, n;
  cin >> m;
  l = L = 0;
  r = R = 0x3fffffff;
  int pre1, pre2;
  while (m--) {
    scanf("%d%d", &pre1, &pre2);
    if (pre1 > L) L = pre1;
    if (pre2 < R) R = pre2;
  }
  cin >> n;
  while (n--) {
    scanf("%d%d", &pre1, &pre2);
    if (pre1 > l) l = pre1;
    if (pre2 < r) r = pre2;
  }
  if (l > R && L > r)
    cout << max(l - R, L - r) << endl;
  else if (L > r)
    cout << L - r << endl;
  else if (l > R)
    cout << l - R << endl;
  else
    cout << '0' << endl;
}
