#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int maxi1 = 0;
  int mini1 = 1e9;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    maxi1 = max(maxi1, a);
    mini1 = min(mini1, b);
  }
  int m;
  cin >> m;
  int maxi2 = 0;
  int mini2 = 1e9;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    maxi2 = max(maxi2, a);
    mini2 = min(mini2, b);
  }
  cout << max(max((maxi1 - mini2), 0), max((maxi2 - mini1), 0)) << endl;
  return 0;
}
