#include <bits/stdc++.h>
using namespace std;
int n, m, minv = 1 << 31 - 1, maxv = 1 << 31, mi = 1 << 31 - 1, ma = 1 << 31,
          ans;
pair<int, int> p[200005], t[200005];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> t[i].first >> t[i].second;
  }
  for (int i = 0; i < n; i++) {
    minv = min(p[i].second, minv);
    ma = max(p[i].first, ma);
  }
  for (int i = 0; i < m; i++) {
    maxv = max(t[i].first, maxv);
    mi = min(t[i].second, mi);
  }
  ans = max(ma - mi, maxv - minv);
  if (ans <= 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
