#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j, k, minn1 = 1000000007, maxx1 = 0,
                               minn2 = 1000000007, maxx2 = 0;
  cin >> n;
  while (n--) {
    cin >> j >> k;
    if (k < minn1) {
      minn1 = k;
    }
    if (j > maxx1) {
      maxx1 = j;
    }
  }
  cin >> m;
  while (m--) {
    cin >> j >> k;
    if (j > maxx2) {
      maxx2 = j;
    }
    if (k < minn2) {
      minn2 = k;
    }
  }
  j = ((maxx2 - minn1) > (maxx1 - minn2) ? (maxx2 - minn1) : (maxx1 - minn2));
  cout << (j > 0 ? j : 0) << endl;
  return 0;
}
