#include <bits/stdc++.h>
using namespace std;
int compare(const void *aa, const void *bb) {
  int *a = (int *)aa;
  int *b = (int *)bb;
  if (a[1] < b[1])
    return -1;
  else if (a[1] == b[1])
    return 0;
  else
    return 1;
}
int comparee(const void *aa, const void *bb) {
  int *a = (int *)aa;
  int *b = (int *)bb;
  if (a[0] > b[0])
    return -1;
  else if (a[0] == b[0])
    return 0;
  else
    return 1;
}
int main() {
  int n;
  cin >> n;
  int arr[n][2];
  for (int i = 0; i < n; i++) {
    cin >> arr[i][0];
    cin >> arr[i][1];
  }
  int m;
  cin >> m;
  int ar[m][2];
  for (int i = 0; i < m; i++) {
    cin >> ar[i][0] >> ar[i][1];
  }
  qsort(arr, n, sizeof(arr[1]), compare);
  qsort(ar, m, sizeof(ar[0]), comparee);
  int ans = ar[0][0] - arr[0][1];
  qsort(arr, n, sizeof(arr[0]), comparee);
  qsort(ar, m, sizeof(ar[1]), compare);
  ans = max(ans, arr[0][0] - ar[0][1]);
  if (ans < 0)
    cout << "0";
  else
    cout << ans;
  return 0;
}
