#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265;
const int INF = 1 << 30;
const int maxn = (1e5) + 50;
const int mod = (1e9) + 7;
const int lim = (1e5);
const char filename_in[] = "in.txt";
const char filename_ou[] = "ou.txt";
long long a, b = INF, c, d = INF;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, x, y, ans = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    a = max(a, x);
    b = min(b, y);
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    c = max(c, x);
    d = min(d, y);
  }
  cout << ((max(a - d, c - b) <= 0) ? 0 : max(a - d, c - b)) << endl;
}
