#include <bits/stdc++.h>
using namespace std;
long long n, m;
pair<long long, long long> a[200005], b[200005];
bool comp1(pair<long long, long long> x, pair<long long, long long> y) {
  return x.second < y.second;
}
void solve() {
  cin >> n;
  for (__typeof((n + 1)) i = (1); i < (n + 1); i++)
    cin >> a[i].first >> a[i].second;
  cin >> m;
  for (__typeof((m + 1)) i = (1); i < (m + 1); i++)
    cin >> b[i].first >> b[i].second;
  sort(a + 1, a + n + 1, comp1);
  sort(b + 1, b + m + 1);
  long long c = max(0ll, b[m].first - a[1].second);
  sort(a + 1, a + n + 1);
  sort(b + 1, b + m + 1, comp1);
  c = max(c, max(0ll, a[n].first - b[1].second));
  cout << c << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
