#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k, m, minend1 = -1, maxstart2 = -1, minend2 = -1, maxstart1 = -1;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> j >> k;
    if (minend1 == -1 || minend1 > k) minend1 = k;
    if (maxstart1 < j) maxstart1 = j;
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> j >> k;
    if (minend2 == -1 || minend2 > k) minend2 = k;
    if (maxstart2 < j) maxstart2 = j;
  }
  cout << max(0, max(-minend1 + maxstart2, maxstart1 - minend2));
  return 0;
}
