#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, minRight1, maxLeft1, minRight2, maxLeft2;
  long long l, r;
  minRight1 = minRight2 = INT_MAX;
  maxLeft1 = maxLeft2 = 0;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> l >> r;
    minRight1 = min(minRight1, r);
    maxLeft1 = max(maxLeft1, l);
  }
  cin >> m;
  for (long long i = 0; i < m; ++i) {
    cin >> l >> r;
    minRight2 = min(minRight2, r);
    maxLeft2 = max(maxLeft2, l);
  }
  long long result = 0;
  result = max(result, maxLeft1 - minRight2);
  result = max(result, maxLeft2 - minRight1);
  cout << result << endl;
  return 0;
}
