#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > ch1(n);
  vector<pair<int, int> > ch2(n);
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    ch1[i].second = l;
    ch1[i].first = r;
    ch2[i].first = l;
    ch2[i].second = r;
  }
  sort(ch1.begin(), ch1.end());
  sort(ch2.begin(), ch2.end(), greater<pair<int, int> >());
  int m;
  cin >> m;
  vector<pair<int, int> > pr1(m);
  vector<pair<int, int> > pr2(m);
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    pr1[i].first = l;
    pr1[i].second = r;
    pr2[i].second = l;
    pr2[i].first = r;
  }
  sort(pr1.begin(), pr1.end(), greater<pair<int, int> >());
  sort(pr2.begin(), pr2.end());
  int ans = 0;
  if (ch1[0].first < pr1[0].first) {
    ans = pr1[0].first - ch1[0].first;
  }
  if (pr2[0].first < ch2[0].first) {
    ans = max(ans, ch2[0].first - pr2[0].first);
  }
  cout << ans << endl;
  return 0;
}
