#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, ans = 1e9 + 1, ans1 = 0, x, y, jvb = 0, jvb1 = 1e9 + 1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    ans = min(y, ans);
    jvb = max(x, jvb);
  }
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y;
    ans1 = max(x, ans1);
    jvb1 = min(jvb1, y);
  }
  cout << max(max(ans1 - ans, jvb - jvb1), (long long)0);
}
