#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int min1 = INT_MAX, min2 = INT_MAX, max2 = INT_MIN, max1 = INT_MIN, m1 = 0,
      m2 = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (min1 > b) min1 = b;
    if (max1 < a) max1 = a;
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (min2 > b) min2 = b;
    if (max2 < a) max2 = a;
  }
  if (max2 > min1) m1 = max2 - min1;
  if (max1 > min2) m2 = max1 - min2;
  int ans = max(m1, m2);
  if (ans > 0)
    cout << ans << endl;
  else
    cout << 0 << endl;
}
