#include <bits/stdc++.h>
using namespace std;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 7;
const long double eps = 1e-9;
const double PI = atan(1) * 4;
template <typename T>
inline int sign(const T &a) {
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
template <typename T, typename S>
inline bool upmin(T &a, const S &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T, typename S>
inline bool upmax(T &a, const S &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline void in(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
long long twop(int x) { return 1LL << x; }
template <typename A, typename B>
inline void in(A &x, B &y) {
  in(x);
  in(y);
}
template <typename A, typename B, typename C>
inline void in(A &x, B &y, C &z) {
  in(x);
  in(y);
  in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A &x, B &y, C &z, D &d) {
  in(x);
  in(y);
  in(z);
  in(d);
}
int dis(pair<int, int> a, pair<int, int> b) {
  int l = max(a.first, b.first);
  int r = min(a.second, b.second);
  if (l <= r) return 0;
  if (a.second < b.first) return b.first - a.second;
  return a.first - b.second;
}
int main() {
  int ans = 0;
  int n, m;
  in(n);
  vector<pair<int, int> > a(n);
  ;
  for (long long i = 0; i < n; i++) in(a[i].first, a[i].second);
  in(m);
  vector<pair<int, int> > b(m);
  for (long long i = 0; i < m; i++) in(b[i].first, b[i].second);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end(),
       [](pair<int, int> a, pair<int, int> b) { return a.second < b.second; });
  upmax(ans, dis(a[0], b.back()));
  upmax(ans, dis(a.back(), b[0]));
  swap(a, b);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end(),
       [](pair<int, int> a, pair<int, int> b) { return a.second < b.second; });
  upmax(ans, dis(a[0], b.back()));
  upmax(ans, dis(a.back(), b[0]));
  cout << ans;
  return 0;
}
