#include <bits/stdc++.h>
using namespace std;
bool sort_d(long long x, long long y) { return x > y; }
int gcd(long long x, long long y) {
  if (!y)
    return x;
  else
    return gcd(y, x % y);
}
int lcm(long long x, long long y) { return (x * y) / gcd(x, y); }
int main() {
  int n, m, a, b;
  std::vector<int> Cs, Ce, Ps, Pe;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    Cs.push_back(a);
    Ce.push_back(b);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    Ps.push_back(a);
    Pe.push_back(b);
  }
  sort(Cs.begin(), Cs.end());
  sort(Ce.begin(), Ce.end());
  sort(Ps.begin(), Ps.end());
  sort(Pe.begin(), Pe.end());
  a = max(Ps[Ps.size() - 1] - Ce[0], 0);
  b = max(Cs[Cs.size() - 1] - Pe[0], 0);
  cout << max(a, b) << endl;
  return 0;
}
