#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m, ans1, ans2;
  cin >> n;
  int ch1[n], ch2[n];
  for (int i = 0; i < n; i++) {
    cin >> ch2[i] >> ch1[i];
  }
  cin >> m;
  int pr1[m], pr2[m];
  for (int i = 0; i < m; i++) {
    cin >> pr1[i] >> pr2[i];
  }
  sort(ch1, ch1 + n);
  sort(pr1, pr1 + m);
  ans1 = pr1[m - 1] - ch1[0];
  sort(ch2, ch2 + n);
  sort(pr2, pr2 + m);
  ans2 = ch2[n - 1] - pr2[0];
  cout << max(0, max(ans1, ans2));
  return 0;
}
