#include <bits/stdc++.h>
using namespace std;
const long long p = 1e9 + 7;
const long double pi = 3.1415926535898;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long binpow(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2) {
    return (binpow(a, n - 1) * a) % p;
  } else {
    long long b = binpow(a, n / 2);
    return (b * b) % p;
  }
}
bool prime(long long k) {
  if (k == 1) return 0;
  for (long long i = 2; i * i <= k; i++)
    if (k % i == 0) return 0;
  return 1;
}
int l1[200000];
int r1[200000];
int l2[200000];
int r2[200000];
int main() {
  int n, m, ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &l1[i]), scanf("%d", &r1[i]);
  cin >> m;
  for (int i = 0; i < m; i++) scanf("%d", &l2[i]), scanf("%d", &r2[i]);
  sort(l1, l1 + n);
  sort(l2, l2 + m);
  sort(r1, r1 + n);
  sort(r2, r2 + m);
  cout << max(l2[m - 1] - r1[0], max(l1[n - 1] - r2[0], 0));
  return 0;
}
