#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int minr = 1e9 + 2;
  int maxl = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    if (l > maxl) {
      maxl = l;
    }
    if (r < minr) {
      minr = r;
    }
  }
  int m;
  cin >> m;
  int minr2 = 1e9 + 2;
  int maxl2 = 0;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    if (l > maxl2) {
      maxl2 = l;
    }
    if (r < minr2) {
      minr2 = r;
    }
  }
  int diff1 = maxl - minr2;
  int diff2 = maxl2 - minr;
  int sol = max(max(diff1, diff2), 0);
  cout << sol << "\n";
  return 0;
}
