#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n, c = 0, m, ans = 0;
  string s;
  cin >> n;
  int l1, r1, l2, r2, max1 = 0, max2 = 0, min1 = 1000000000, min2 = 1000000000;
  for (int i = 0; i < n; i++) {
    cin >> r1 >> l1;
    if (max1 < r1) max1 = r1;
    if (min1 > l1) min1 = l1;
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> r2 >> l2;
    if (max2 < r2) max2 = r2;
    if (min2 > l2) min2 = l2;
  }
  if (max2 - min1 >= 0) ans = max2 - min1;
  if (max1 - min2 > ans) ans = max1 - min2;
  cout << ans;
  return 0;
}
