#include <bits/stdc++.h>
using namespace std;
long long int arr1[1000001][2], arr2[1000001][2];
long long int chesss(long long int, long long int);
long long int prog(long long int, long long int);
int main() {
  long long int n, m, i, j, res1, res2;
  cin >> n;
  for (i = 0; i < n; i++) {
    for (j = 0; j < 2; j++) cin >> arr1[i][j];
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    for (j = 0; j < 2; j++) cin >> arr2[i][j];
  }
  res1 = chesss(n, m);
  res2 = prog(n, m);
  if (res1 >= res2)
    cout << res1 << '\n';
  else
    cout << res2 << '\n';
  return 0;
}
long long int chesss(long long int n, long long int m) {
  long long int i, p, s = 0, g = 0;
  for (i = 1; i < n; i++) {
    if (arr1[i][1] < arr1[s][1]) s = i;
  }
  for (i = 1; i < m; i++) {
    if (arr2[i][0] > arr2[g][0]) g = i;
  }
  p = arr2[g][0] - arr1[s][1];
  if (p < 0)
    return 0;
  else
    return p;
}
long long int prog(long long int n, long long int m) {
  long long int i, q, s = 0, g = 0;
  for (i = 1; i < m; i++) {
    if (arr2[i][1] < arr2[s][1]) s = i;
  }
  for (i = 1; i < n; i++) {
    if (arr1[i][0] > arr1[g][0]) g = i;
  }
  q = arr1[g][0] - arr2[s][1];
  if (q < 0)
    return 0;
  else
    return q;
}
