#include <bits/stdc++.h>
using namespace std;
const long long MOD9 = 1e9 + 7;
const long long MAX = 1e6 + 10;
const double eps = 0.99;
int dx[4] = {0, 0, 1, -1};
int dy[4] = {-1, 1, 0, 0};
int t, z, n, m, k;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  int x, y, a, b, c, d;
  a = b = 0;
  c = d = 1e9;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    a = max(a, x), c = min(c, y);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    b = max(b, x), d = min(d, y);
  }
  int v1, v2;
  v1 = max(0, b - c);
  v2 = max(0, a - d);
  cout << max(v1, v2);
}
