#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  int b, e, chn;
  cin >> chn;
  vector<pair<int, int> > chess(chn);
  for (int i = 0; i < chn; i++) {
    cin >> b >> e;
    chess[i].first = b;
    chess[i].second = e;
  }
  int pron;
  cin >> pron;
  vector<pair<int, int> > prog(pron);
  for (int i = 0; i < pron; i++) {
    cin >> b >> e;
    prog[i].first = b;
    prog[i].second = e;
  }
  sort(chess.begin(), chess.end(), sortbysec);
  sort(prog.rbegin(), prog.rend());
  int t1, t2;
  t1 = prog[0].first - chess[0].second;
  sort(chess.rbegin(), chess.rend());
  sort(prog.begin(), prog.end(), sortbysec);
  t2 = chess[0].first - prog[0].second;
  if (max(t1, t2) > 0)
    cout << max(t2, t1) << endl;
  else
    cout << 0 << endl;
  return 0;
}
