#include <bits/stdc++.h>
using namespace std;
struct data {
  int x;
  int y;
};
int main() {
  long long n;
  cin >> n;
  vector<data> info;
  long long smallest = 9999999999;
  long long largest2 = -1;
  for (int i = 0; i < n; i++) {
    data temp;
    cin >> temp.x >> temp.y;
    if (temp.y < smallest) {
      smallest = temp.y;
    }
    if (temp.x > largest2) {
      largest2 = temp.x;
    }
    info.push_back(temp);
  }
  long long m;
  cin >> m;
  vector<data> info2;
  long long largest = -1;
  long long smallest2 = 9999999999;
  for (int i = 0; i < m; i++) {
    data temp;
    cin >> temp.x >> temp.y;
    if (temp.x > largest) {
      largest = temp.x;
    }
    if (temp.y < smallest2) {
      smallest2 = temp.y;
    }
    info2.push_back(temp);
  }
  cout << max(max(largest - smallest, largest2 - smallest2), (long long)0)
       << endl;
  return 0;
}
