#include <bits/stdc++.h>
using namespace std;
int mypowerfun(int arr, int b) {
  if (b == 0) return 1;
  if (b == 1) return arr;
  int x = mypowerfun(arr, b / 2);
  if (b % 2 == 0)
    return x * x;
  else
    return x * x * arr;
}
void pri_arr(int arr[], int n) {
  int i;
  for (i = 0; i < n; i++) printf("%d ", arr[i]);
  printf("\n");
}
void pri_vec(vector<int> a, int n) {
  for (std::vector<int>::iterator it = a.begin(); it != a.end(); ++it)
    std::cout << *it;
  std::cout << '\n';
}
int mygcd(int arr, int b) {
  if (b != 0)
    return mygcd(b, arr % b);
  else
    return arr;
}
int dist(int l, int r, int L, int R);
bool cmpl(pair<int, int> x, pair<int, int> y);
bool cmpr(pair<int, int> x, pair<int, int> y);
int main() {
  int n;
  cin >> n;
  pair<int, int> a[n];
  for (int k = 0; k < n; k++) cin >> a[k].first >> a[k].second;
  int m;
  cin >> m;
  pair<int, int> b[m];
  for (int k = 0; k < m; k++) cin >> b[k].first >> b[k].second;
  int Max = 0;
  sort(a, a + n, cmpr);
  sort(b, b + m, cmpl);
  Max =
      max(Max, dist(a[0].first, a[0].second, b[m - 1].first, b[m - 1].second));
  sort(a, a + n, cmpl);
  sort(b, b + m, cmpr);
  Max =
      max(Max, dist(a[n - 1].first, a[n - 1].second, b[0].first, b[0].second));
  cout << Max << endl;
  return 0;
}
bool cmpl(pair<int, int> x, pair<int, int> y) {
  if (x.first < y.first) return true;
  if (x.first > y.first) return false;
  return (x.second < y.second);
}
bool cmpr(pair<int, int> x, pair<int, int> y) {
  if (x.second < y.second) return true;
  if (x.second > y.second) return false;
  return (x.first < y.first);
}
int dist(int l, int r, int L, int R) {
  if (max(l, L) <= min(r, R))
    return 0;
  else if (r <= L)
    return L - r;
  else if (R <= l)
    return l - R;
}
