#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  int n, m;
  cin >> n;
  vector<pair<int, int> > v1(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> v1[i].first >> v1[i].second;
  }
  cin >> m;
  vector<pair<int, int> > v2(m + 1);
  for (int i = 1; i <= m; i++) {
    cin >> v2[i].first >> v2[i].second;
  }
  int minR1 = 0x3f3f3f3f, maxL1 = -0x3f3f3f3f;
  int minR2 = 0x3f3f3f3f, maxL2 = -0x3f3f3f3f;
  for (int i = 1; i <= n; i++) {
    maxL1 = max(maxL1, v1[i].first);
    minR1 = min(minR1, v1[i].second);
  }
  for (int i = 1; i <= m; i++) {
    maxL2 = max(maxL2, v2[i].first);
    minR2 = min(minR2, v2[i].second);
  }
  int res = max(maxL2 - minR1, maxL1 - minR2);
  cout << max(res, 0) << '\n';
  return 0;
}
