#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
int n, m;
const int N = (int)1e9 + 1;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  vector<pair<int, int>> vn(n);
  for (auto &i : vn) cin >> i.first >> i.second;
  cin >> m;
  vector<pair<int, int>> vm(m);
  for (auto &i : vm) cin >> i.first >> i.second;
  int mn1 = N, mn2 = N, mx1 = -N, mx2 = -N;
  for (auto i : vn) mn1 = min(mn1, i.second), mx1 = max(mx1, i.first);
  for (auto i : vm) mn2 = min(mn2, i.second), mx2 = max(mx2, i.first);
  cout << max(max(mx2 - mn1, mx1 - mn2), 0);
  return 0;
}
