#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
int IT_MAX = 1 << 17;
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 1234567890123456789ll;
const double PI = acos(-1);
const double ERR = 1E-11;
int main() {
  int mn1 = INF, mx1 = -INF, mn2 = INF, mx2 = -INF;
  int N, M, i, j;
  scanf("%d", &N);
  while (N--) {
    scanf("%d %d", &i, &j);
    mx1 = max(mx1, i);
    mn1 = min(mn1, j);
  }
  scanf("%d", &M);
  while (M--) {
    scanf("%d %d", &i, &j);
    mx2 = max(mx2, i);
    mn2 = min(mn2, j);
  }
  int ans = 0;
  ans = max(ans, mx2 - mn1);
  ans = max(ans, mx1 - mn2);
  return !printf("%d\n", ans);
}
