#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n;
  scanf("%ld", &n);
  pair<long int, long int> A[n];
  for (int i = 0; i < n; i++) {
    scanf("%ld", &A[i].first);
    scanf("%ld", &A[i].second);
  }
  long int m;
  scanf("%ld", &m);
  pair<long int, long int> B[m];
  for (int i = 0; i < m; i++) {
    scanf("%ld", &B[i].first);
    scanf("%ld", &B[i].second);
  }
  long int sum = 0;
  long int L1 = INT_MIN, R1 = INT_MAX, L2 = INT_MIN, R2 = INT_MAX;
  for (long int i = 0; i < n; i++) {
    L1 = max(L1, A[i].first);
    R1 = min(R1, A[i].second);
  }
  for (long int i = 0; i < m; i++) {
    L2 = max(L2, B[i].first);
    R2 = min(R2, B[i].second);
  }
  sum = max(L2 - R1, L1 - R2);
  printf("%ld\n", max(sum, 0L));
  return 0;
}
