#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, x, y;
  cin >> n;
  int frmin = INT_MAX, flmax = -1, srmin = INT_MAX, slmax = -1;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    frmin = min(frmin, y);
    flmax = max(flmax, x);
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    srmin = min(srmin, y);
    slmax = max(slmax, x);
  }
  long long int ans = 1e10;
  if (slmax >= frmin) {
    ans = slmax - frmin;
  }
  if (flmax >= srmin) {
    int cur = flmax - srmin;
    if (cur > ans || ans == 1e10) ans = cur;
  }
  if (ans == 1e10)
    cout << 0;
  else
    cout << ans;
  return 0;
}
