#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int max1 = 0, max2 = 0, min1 = (1000000000 + 9),
                min2 = (1000000000 + 9);
  for (int i = 0; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    if (y < min1) {
      min1 = y;
    }
    if (x > max1) {
      max1 = x;
    }
  }
  long long int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    long long int x, y;
    cin >> x >> y;
    if (y < min2) {
      min2 = y;
    }
    if (x > max2) {
      max2 = x;
    }
  }
  long long int x1 = (max1 - min2);
  long long int x2 = (max2 - min1);
  long long int x3 = max(x1, x2);
  if (x3 < 0) {
    cout << 0 << endl;
  } else {
    cout << x3 << endl;
  }
}
