#include <bits/stdc++.h>
using namespace std;
const int MAXN = (1 << 20);
int n, m;
pair<int, int> a[MAXN], b[MAXN];
void read() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  cin >> m;
  for (int i = 0; i < m; i++) cin >> b[i].first >> b[i].second;
}
void solve() {
  int mn_en1 = 1e9 + 42, mn_en2 = 1e9 + 42;
  int mx_en1 = -1e9 + -42, mx_en2 = -1e9 + -42;
  for (int i = 0; i < n; i++) {
    mn_en1 = min(mn_en1, a[i].second);
    mx_en1 = max(mx_en1, a[i].first);
  }
  for (int i = 0; i < m; i++) {
    mn_en2 = min(mn_en2, b[i].second);
    mx_en2 = max(mx_en2, b[i].first);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, (a[i].first - mn_en2));
    ans = max(ans, (mx_en2 - a[i].second));
  }
  for (int i = 0; i < m; i++) {
    ans = max(ans, (b[i].first - mn_en1));
    ans = max(ans, (mx_en1 - b[i].second));
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
