#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, w = 0, x = pow(10, 10), y = 0, z = pow(10, 10);
  cin >> n;
  long int a[n], b[n];
  for (i = 0; i < n; i++) cin >> a[i] >> b[i];
  cin >> m;
  long int c[m], d[m];
  for (i = 0; i < m; i++) cin >> c[i] >> d[i];
  for (i = 0; i < n; i++) {
    if (a[i] > w) w = a[i];
    if (b[i] < x) x = b[i];
  }
  for (i = 0; i < m; i++) {
    if (c[i] > y) y = c[i];
    if (d[i] < z) z = d[i];
  }
  if ((w - z) <= 0 && (y - x) <= 0)
    cout << 0;
  else
    cout << max(w - z, y - x);
  return 0;
}
