#include <bits/stdc++.h>
using namespace std;
int minR(vector<pair<int, int> >& vec) {
  int x = 1E9;
  for (auto& p : vec) {
    if (p.second < x) x = p.second;
  }
  return x;
}
int maxL(vector<pair<int, int> >& vec) {
  int x = -1;
  for (auto& z : vec) {
    if (z.first > x) x = z.first;
  }
  return x;
}
int main(void) {
  int n;
  cin >> n;
  vector<pair<int, int> > chess(n);
  for (int i = 0; i != n; i++) cin >> chess[i].first >> chess[i].second;
  int m;
  cin >> m;
  vector<pair<int, int> > prog(m);
  for (auto& x : prog) cin >> x.first >> x.second;
  int fd = maxL(prog) - minR(chess);
  int sd = maxL(chess) - minR(prog);
  int mx = fd > sd ? fd : sd;
  if (mx < 0) mx = 0;
  cout << mx << "\n";
  return 0;
}
