#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int length;
  int nl = 0, nr = 1000000001, ml = 0, mr = 1000000001;
  int t1, t2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t1 >> t2;
    if (nl < t1) nl = t1;
    if (nr > t2) nr = t2;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> t1 >> t2;
    if (ml < t1) ml = t1;
    if (mr > t2) mr = t2;
  }
  if (nr < ml)
    length = ml - nr;
  else
    length = 0;
  if (mr < nl) length = max(length, nl - mr);
  cout << length;
  return 0;
}
