#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  long long int m, cnt = 0, maxi = 0;
  cin >> m;
  long long int c[m], d[m];
  for (int i = 0; i < m; i++) {
    cin >> c[i] >> d[i];
  }
  sort(a, a + n);
  sort(b, b + n);
  sort(c, c + m);
  sort(d, d + m);
  cout << max(0LL, max(c[m - 1] - b[0], a[n - 1] - d[0]));
}
