#include <bits/stdc++.h>
using namespace std;
int main() {
  int min1 = INT_MAX, min2 = INT_MAX, max1 = -1, max2 = -1;
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    min1 = min(min1, x);
    max1 = max(max1, x);
    min2 = min(min2, y);
    max2 = max(max2, y);
  }
  int min3 = INT_MAX, min4 = INT_MAX, max3 = -1, max4 = -1;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    min3 = min(min3, x);
    max3 = max(max3, x);
    min4 = min(min4, y);
    max4 = max(max4, y);
  }
  int ans1, ans2, ans3;
  ans1 = max3 - min2;
  ans2 = max1 - min4;
  ans1 = max(0, max(ans1, ans2));
  printf("%d\n", ans1);
}
