#include <bits/stdc++.h>
using namespace std;
vector<int> k11, k12, k21, k22;
long long mdl(long long x) {
  if (x > 0)
    return x;
  else
    return -x;
}
int main() {
  int n, a, b, m;
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    k11.push_back(a);
    k12.push_back(b);
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    k21.push_back(a);
    k22.push_back(b);
  }
  sort(k11.begin(), k11.end());
  sort(k12.begin(), k12.end());
  sort(k21.begin(), k21.end());
  sort(k22.begin(), k22.end());
  cout << max(max(k11[n - 1] - k22[0], k21[m - 1] - k12[0]), 0);
  return 0;
}
