#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, s, e;
  vector<pair<int, int> > cfin, cstrt, pfin, pstrt;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s >> e;
    cfin.push_back(make_pair(e, s));
    cstrt.push_back(make_pair(s, e));
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> s >> e;
    pfin.push_back(make_pair(e, s));
    pstrt.push_back(make_pair(s, e));
  }
  sort(cfin.begin(), cfin.end());
  sort(cstrt.begin(), cstrt.end());
  sort(pfin.begin(), pfin.end());
  sort(pstrt.begin(), pstrt.end());
  int ans = 0;
  ans = max(ans, max(pstrt[m - 1].first - cfin[0].first,
                     cstrt[n - 1].first - pfin[0].first));
  cout << ans << endl;
  return 0;
}
