#include <bits/stdc++.h>
using namespace std;
int n, max1, min1, max2, min2, l, r, ans;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  min1 = min2 = 1000000007;
  max1 = max2 = -1000000007;
  while (n--) {
    cin >> l >> r;
    max1 = max(max1, l);
    min1 = min(min1, r);
  }
  cin >> n;
  while (n--) {
    cin >> l >> r;
    max2 = max(max2, l);
    min2 = min(min2, r);
  }
  ans = max(ans, (max2 - min1));
  ans = max(ans, (max1 - min2));
  cout << ans;
}
