#include using namespace std; using i64 = long long; const int N = 2e5 + 10, M = 2e3 + 10; int n, x[N], y[N]; int g[M][M]; int ask(int x1, int y1, int x2, int y2) { if(x1 < 0) x1 = 0; if(y1 < 0) y1 = 0; if(x2 >= M) x2 = M - 1; if(y2 >= M) y2 = M - 1; return g[x2][y2] - g[x2][y1] - g[x1][y2] + g[x1][y1]; } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 1, a, b; i <= n; i ++) { cin >> a >> b; x[i] = a + b + 1; y[i] = a - b + 1001; } int m; cin >> m; for(int i = 1, a, b, x, y; i <= m; i ++) { cin >> a >> b; x = a + b + 1; y = a - b + 1001; g[x][y] ++; } for(int i = 1; i < M; i ++) for(int j = 1; j < M; j ++) g[i][j] += g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1]; int l = -1, r = M; while(l + 1 < r) { int mid = (l + r) / 2; bool found = false; for(int i = 1; i <= n && !found; i ++) if(ask(x[i] - mid - 1, y[i] - mid - 1, x[i] + mid, y[i] + mid)) found = true; if(found) r = mid; else l = mid; } cout << r; }