#include <bits/stdc++.h>
using namespace std;
const int N = 10000;
const int inf = (int)1e9 + 1;
const long long big = (long long)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-6;
const double pi = atan2(0, -1);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  int n;
  cin >> n;
  vector<pair<int, int> > a(n);
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  int m;
  cin >> m;
  vector<pair<int, int> > b(m);
  for (int i = 0; i < m; i++) cin >> b[i].first >> b[i].second;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int ans = 0;
  for (int i = 0; i < n; i++) ans = max(ans, b[m - 1].first - a[i].second);
  for (int i = 0; i < m; i++) ans = max(ans, a[n - 1].first - b[i].second);
  cout << ans << endl;
  return 0;
}
