#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n;
  vector<long long> v1, v2, v3, v4;
  for (int i = 1; i <= n; i++) {
    long long l, r;
    cin >> l >> r;
    v1.push_back(r);
    v3.push_back(l);
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int l, r;
    cin >> l >> r;
    v2.push_back(l);
    v4.push_back(r);
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  sort(v3.begin(), v3.end());
  sort(v4.begin(), v4.end());
  long long res = v2[v2.size() - 1] - v1[0];
  long long result = v3[v3.size() - 1] - v4[0];
  long long res1 = max(res, result);
  if (res1 < 0) res1 = 0;
  cout << res1 << endl;
  return 0;
}
