#include <bits/stdc++.h>
using namespace std;
long long int a[1000000], b[1000000];
long long int c[1000000], d[1000000];
int main() {
  long long int n, m;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  cin >> m;
  for (long long int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  long long int maxa = a[0], maxc = c[0], minb = b[0], mind = d[0];
  for (long long int i = 0; i < n; i++) {
    if (maxa < a[i]) {
      maxa = a[i];
    }
    if (minb > b[i]) {
      minb = b[i];
    }
  }
  for (long long int i = 0; i < m; i++) {
    if (maxc < c[i]) {
      maxc = c[i];
    }
    if (mind > d[i]) {
      mind = d[i];
    }
  }
  long long int num1 = maxc - minb;
  long long int num2 = maxa - mind;
  if ((num1 < 0) && (num2 < 0)) {
    cout << 0;
    return 0;
  }
  if (num1 > num2) {
    cout << num1;
  } else {
    cout << num2;
  }
  return 0;
}
