#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, x, y;
  cin >> n;
  long long int l1, r1, l2, r2, min, max = 0;
  min = 9999999999;
  for (long long int i = 0; i < n; i++) {
    cin >> x;
    cin >> y;
    if (y < min) {
      min = y;
      l1 = x;
      r1 = y;
    }
    if (x > max) {
      max = x;
      l2 = x;
      r2 = y;
    }
  }
  cin >> m;
  long long int l3, r3, l4, r4, max1 = 0, min1 = 9999999999, dist1, dist2, f;
  for (long long int i = 0; i < m; i++) {
    cin >> x;
    cin >> y;
    if (y < min1) {
      min1 = y;
      l3 = x;
      r3 = y;
    }
    if (x > max1) {
      max1 = x;
      l4 = x;
      r4 = y;
    }
  }
  if (l4 > r1) {
    dist1 = l4 - r1;
  } else
    dist1 = 0;
  if (r3 < l2)
    dist2 = l2 - r3;
  else
    dist2 = 0;
  if (dist1 > dist2)
    f = dist1;
  else
    f = dist2;
  cout << f << endl;
  return 0;
}
