#include <bits/stdc++.h>
using namespace std;
int i;
int l1[200001], r1[200001], l2[200001], r2[200001];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> l1[i] >> r1[i];
  }
  cin >> m;
  for (i = 0; i < m; i++) {
    cin >> l2[i] >> r2[i];
  }
  int diff = 0;
  sort(l1, l1 + n);
  sort(r1, r1 + n);
  sort(l2, l2 + m);
  sort(r2, r2 + m);
  if (l2[m - 1] - r1[0] > 0 || -r2[0] + l1[n - 1] > 0)
    diff = max(-r1[0] + l2[m - 1], -r2[0] + l1[n - 1]);
  cout << diff << endl;
  return 0;
}
