#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > c1;
  vector<pair<long long, long long> > c2;
  for (long long i = 0; i < n; i++) {
    long long l, r;
    cin >> l >> r;
    c1.push_back(make_pair(r, l));
    c2.push_back(make_pair(l, r));
  }
  sort(c1.begin(), c1.end());
  sort(c2.begin(), c2.end());
  long long m;
  cin >> m;
  vector<pair<long long, long long> > p1;
  vector<pair<long long, long long> > p2;
  for (long long i = 0; i < m; i++) {
    long long l, r;
    cin >> l >> r;
    p1.push_back(make_pair(l, r));
    p2.push_back(make_pair(r, l));
  }
  sort(p1.begin(), p1.end());
  sort(p2.begin(), p2.end());
  long long r = c1[0].first;
  long long l = p1[m - 1].first;
  long long ans = 0;
  if (l > r) {
    ans = max(ans, l - r);
  }
  long long l1 = c2[n - 1].first;
  long long r1 = p2[0].first;
  if (r1 < l1) {
    ans = max(ans, l1 - r1);
  }
  cout << ans << endl;
  return 0;
}
