#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false);
  int n, m;
  int r1_min = INT_MAX, l1_max = -INT_MAX;
  int r2_min = INT_MAX, l2_max = -INT_MAX;
  cin >> n;
  int l1[n], r1[n];
  for (int i = 0; i < n; i++) {
    cin >> l1[i] >> r1[i];
    l1_max = max(l1[i], l1_max);
    r1_min = min(r1[i], r1_min);
  }
  cin >> m;
  int l2[m], r2[m];
  for (int i = 0; i < m; i++) {
    cin >> l2[i] >> r2[i];
    l2_max = max(l2[i], l2_max);
    r2_min = min(r2[i], r2_min);
  }
  int d1 = l2_max - r1_min;
  int d2 = l1_max - r2_min;
  int ans = max(d1, d2);
  if (ans < 0) ans = 0;
  cout << ans << "\n";
}
