#include <bits/stdc++.h>
using namespace std;
long long i, m, n, x, y, a, mn1 = 1e9, mn3 = 1e9, mx2 = -1, mx4 = -1, mx5, b, k;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    mn1 = min(mn1, y);
    mx2 = max(mx2, x);
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> a >> b;
    mn3 = min(mn3, b);
    mx4 = max(mx4, a);
  }
  k = 0;
  mx5 = max(mx4 - mn1, mx2 - mn3);
  mx5 = max(mx5, k);
  cout << mx5;
}
