#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, max_al, max_bl, min_ar, min_br;
  scanf("%d", &n);
  max_al = max_bl = 0;
  min_ar = min_br = 2e9;
  for (int i = 1; i <= n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    max_al = max(max_al, l);
    min_ar = min(min_ar, r);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    max_bl = max(max_bl, l);
    min_br = min(min_br, r);
  }
  int ret = max(0, max(max_al - min_br, max_bl - min_ar));
  cout << ret << endl;
}
