#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int l, r;
  int cminm = 1000000000, pminm = 1000000000, cmaxm = 0, pmaxm = 0;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    cminm = min(cminm, r);
    cmaxm = max(cmaxm, l);
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    pminm = min(pminm, r);
    pmaxm = max(pmaxm, l);
  }
  int ans1 = pmaxm - cminm;
  int ans2 = cmaxm - pminm;
  if (ans1 < 0) ans1 = 0;
  if (ans2 < 0) ans2 = 0;
  cout << max(ans1, ans2);
}
