#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b, sc, ec, sp, ep;
int main() {
  while (cin >> n) {
    sc = sp = 0;
    ec = ep = 2000000000;
    for (int i = 0; i < n; i++) cin >> a >> b, sc = max(sc, a), ec = min(ec, b);
    cin >> m;
    for (int i = 0; i < m; i++) cin >> a >> b, sp = max(sp, a), ep = min(ep, b);
    int r = 0;
    if (sp - ec > 0) r = max(r, sp - ec);
    if (sc - ep > 0) r = max(r, sc - ep);
    cout << r << "\n";
  }
}
