#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
long long int setbits(long long int x) { return __builtin_popcount(x); }
const long long int MOD = 1e9 + 7;
const long long int INF = 2e18;
long long int mul(long long int a, long long int b) {
  if (a > INF / b)
    return INF;
  else
    return a * b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  long long int ans = 0;
  pair<long long int, long long int> dur1[n];
  for (long long int i = 0; i < n; i++) cin >> dur1[i].first >> dur1[i].second;
  long long int m;
  cin >> m;
  pair<long long int, long long int> dur2[m];
  for (long long int i = 0; i < m; i++) cin >> dur2[i].first >> dur2[i].second;
  long long int mn = dur1[0].second;
  for (long long int i = 0; i < n; i++) mn = min(mn, dur1[i].second);
  long long int mx = dur2[0].first;
  for (long long int i = 0; i < m; i++) mx = max(mx, dur2[i].first);
  ans = max(mx - mn, (long long int)0);
  mn = dur2[0].second;
  for (long long int i = 0; i < m; i++) mn = min(mn, dur2[i].second);
  mx = dur1[0].first;
  for (long long int i = 0; i < n; i++) mx = max(mx, dur1[i].first);
  ans = max(ans, mx - mn);
  cout << ans;
  return 0;
}
