#include <bits/stdc++.h>
using namespace std;
const long long int N = 100005;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  {
    long long int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
    cin >> n;
    vector<long long int> a;
    vector<long long int> v;
    vector<long long int> c;
    vector<long long int> d;
    for (i = 0; i < n; i++) {
      cin >> j >> k;
      a.push_back(k);
      c.push_back(j);
    }
    cin >> m;
    for (i = 0; i < m; i++) {
      cin >> j >> k;
      v.push_back(j);
      d.push_back(k);
    }
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());
    sort(d.begin(), d.end());
    sort(v.begin(), v.end());
    ans = v[v.size() - 1] - a[0];
    sum = c[c.size() - 1] - d[0];
    ans = max(ans, sum);
    ans = max((long long int)0, ans);
    cout << ans;
  }
}
