#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int i, mx = INT_MIN, mn = INT_MAX, mn1 = INT_MAX, mx1 = INT_MIN;
  long long int q, w, ans;
  for (i = 1; i <= n; i++) {
    long long int x, y;
    cin >> x >> y;
    mx = max(x, mx);
    mn = min(y, mn);
  }
  long long int m;
  cin >> m;
  for (i = 1; i <= m; i++) {
    long long int x, y;
    cin >> x >> y;
    mx1 = max(x, mx1);
    mn1 = min(y, mn1);
  }
  q = mx - mn1;
  w = mx1 - mn;
  ans = max(q, w);
  if (ans <= 0) ans = 0;
  cout << ans;
}
