#include <bits/stdc++.h>
using namespace std;
long long int binarySearch(vector<long long int> v, long long int l,
                           long long int r, long long int x) {
  if (r >= l) {
    long long int mid = l + (r - l) / 2;
    if (v[mid] == x) return mid;
    if (v[mid] > x) return binarySearch(v, l, mid - 1, x);
    return binarySearch(v, mid + 1, r, x);
  }
  return -1;
}
void Solve() {
  long long int n, m, a, b, mx = 0, mx1 = 0, mn = 1000000009, mn1 = 1000000009;
  scanf("%lld", &m);
  for (int i = 0; i < m; i++) {
    scanf("%lld %lld", &a, &b);
    mn = min(mn, b);
    mx1 = max(mx1, a);
  }
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", &a, &b);
    mx = max(mx, a);
    mn1 = min(mn1, b);
  }
  long long int x = max(mx - mn, mx1 - mn1);
  cout << (x >= 0 ? x : 0);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Solve();
  return 0;
}
