#include <bits/stdc++.h>
using namespace std;
int main() {
  priority_queue<int> que1, que2;
  priority_queue<int, vector<int>, greater<int> > qu1, qu2;
  int x;
  scanf("%d", &x);
  while (x--) {
    int a, b;
    scanf("%d%d", &a, &b);
    que1.push(a);
    qu1.push(b);
  }
  scanf("%d", &x);
  while (x--) {
    int a, b;
    scanf("%d%d", &a, &b);
    que2.push(a);
    qu2.push(b);
  }
  int ans = max(que1.top() - qu2.top(), que2.top() - qu1.top());
  if (ans < 0) ans = 0;
  printf("%d\n", ans);
  return 0;
}
