#include <bits/stdc++.h>
using namespace std;
int sb[300000], eb[300000], sc[300000], ec[300000];
int main() {
  int a, e, ans;
  scanf("%d", &a);
  for (int i = 0; i < a; i++) {
    scanf("%d%d", &sb[i], &eb[i]);
  }
  sort(sb, sb + a);
  sort(eb, eb + a);
  scanf("%d", &e);
  for (int i = 0; i < e; i++) {
    scanf("%d%d", &sc[i], &ec[i]);
  }
  sort(sc, sc + e);
  sort(ec, ec + e);
  ans = (sc[e - 1] - eb[0]) > (sb[a - 1] - ec[0]) ? sc[e - 1] - eb[0]
                                                  : sb[a - 1] - ec[0];
  if (ans < 0)
    printf("0\n");
  else
    printf("%d\n", ans);
  return 0;
}
