#include <bits/stdc++.h>
using namespace std;
const int Max = 200010;
struct node {
  int lef, rig;
  void read() { scanf("%d %d", &lef, &rig); }
} num1[Max], num2[Max];
int Solve(int n, int m) {
  int ans = 0;
  int minn = num1[0].rig, manx = num2[0].lef;
  for (int i = 0; i < n; ++i) {
    minn = min(minn, num1[i].rig);
  }
  for (int i = 0; i < m; ++i) {
    manx = max(manx, num2[i].lef);
  }
  ans = max(ans, manx - minn);
  minn = num2[0].rig, manx = num1[0].lef;
  for (int i = 0; i < m; ++i) {
    minn = min(minn, num2[i].rig);
  }
  for (int i = 0; i < n; ++i) {
    manx = max(manx, num1[i].lef);
  }
  ans = max(ans, manx - minn);
  return ans;
}
int main() {
  int n, m;
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; ++i) {
      num1[i].read();
    }
    scanf("%d", &m);
    for (int i = 0; i < m; ++i) {
      num2[i].read();
    }
    printf("%d\n", Solve(n, m));
  }
  return 0;
}
