#include <bits/stdc++.h>
using namespace std;
pair<int, int> chess_first, chess_second;
pair<int, int> programming_first, programming_second;
int main() {
  ios_base::sync_with_stdio(false);
  chess_first.second = INT_MAX / 2;
  chess_second.first = 0;
  programming_first.second = INT_MAX / 2;
  programming_second.first = 0;
  int chess_options, programming_options;
  cin >> chess_options;
  for (int i = 0; i < chess_options; i++) {
    int from, to;
    cin >> from >> to;
    if (to < chess_first.second) {
      chess_first.second = to;
      chess_first.first = from;
    }
    if (from > chess_second.first) {
      chess_second.first = from;
      chess_second.second = to;
    }
  }
  cin >> programming_options;
  for (int i = 0; i < programming_options; i++) {
    int from, to;
    cin >> from >> to;
    if (to < programming_first.second) {
      programming_first.second = to;
      programming_first.first = from;
    }
    if (from > programming_second.first) {
      programming_second.first = from;
      programming_second.second = to;
    }
  }
  cout << max(max(programming_second.first - chess_first.second, 0),
              max(chess_second.first - programming_first.second, 0));
}
