#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<int, int> > chess, prog, chess2, prog2;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    chess.push_back(make_pair(r, l));
    chess2.push_back(make_pair(l, r));
  }
  sort(chess.begin(), chess.end());
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    prog.push_back(make_pair(l, r));
    prog2.push_back(make_pair(r, l));
  }
  sort(prog.rbegin(), prog.rend());
  int x = chess[0].first, y = prog[0].first, ans = 0;
  if (x >= y) {
    ans = max(ans, 0);
  } else {
    ans = max(ans, y - x);
  }
  sort(chess2.rbegin(), chess2.rend());
  sort(prog2.begin(), prog2.end());
  x = prog2[0].first, y = chess2[0].first;
  if (y > x) {
    ans = max(ans, y - x);
  }
  cout << ans << endl;
  return 0;
}
