#include <bits/stdc++.h>
typedef long long ll;
template <typename T>
T gcd(T a, T b) {
  return (b == 0) ? a : gcd(b, a % b);
}
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n, m;
  cin >> n;
  vector<pair<ll, ll> > a, b;
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    a.push_back({x, y});
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    ll x, y;
    cin >> x >> y;
    b.push_back({x, y});
  }
  ll mnA = INT_MAX, mxA = INT_MIN;
  ll mnB = INT_MAX, mxB = INT_MIN;
  for (auto i : a) {
    if (mnA > i.second) mnA = i.second;
    if (mxA < i.first) mxA = i.first;
  }
  for (auto i : b) {
    if (mnB > i.second) mnB = i.second;
    if (mxB < i.first) mxB = i.first;
  }
  ll a1, a2;
  a1 = mxB - mnA;
  a2 = mxA - mnB;
  if (a1 < 0) a1 = 0;
  if (a2 < 0) a2 = 0;
  cout << max(a1, a2);
  return 0;
}
