#include <bits/stdc++.h>
using namespace std;
long long n, m, i, j, t, ans, res, y, mn, mx;
long long a, b, c, d;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  mn = 1e10;
  t = 1e10;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> a >> b;
    mn = min(mn, b);
    mx = max(mx, a);
  }
  cin >> m;
  for (i = 1; i <= m; ++i) {
    cin >> c >> d;
    t = min(t, d);
    y = max(y, c);
  }
  res = 0;
  ans = 0;
  if (y - mn > 0) res = y - mn;
  if (mx - t > 0) res = max(res, mx - t);
  cout << res;
}
