#include <bits/stdc++.h>
using namespace std;
void solve() {
  vector<long long> v1, v2, v3, v4;
  int n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v1.push_back(a);
    v2.push_back(b);
  }
  int m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v3.push_back(a);
    v4.push_back(b);
  }
  sort(v1.begin(), v1.end());
  ;
  sort(v2.begin(), v2.end());
  ;
  sort(v3.begin(), v3.end());
  ;
  sort(v4.begin(), v4.end());
  ;
  cout << max((long long)0, max(v1[n - 1] - v4[0], v3[m - 1] - v2[0]));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
