#include <iostream> #include <vector> using namespace std; const int MAXN = 2e5 + 5, MAXV = 2e3 + 3; int n, m, a[MAXN], b[MAXN], c[MAXV][MAXV]; bool Check(int dis) { for (int i = 1; i <= n; i++) { int lx = max(1, a[i] - dis), rx = min(2000, a[i] + dis); int ly = max(1, b[i] - dis), ry = min(2000, b[i] + dis); if (c[rx][ry] - c[lx - 1][ry] - c[rx][ly - 1] + c[lx - 1][ly - 1] > 0) { return 1; } } return 0; } int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n; for (int i = 1, x, y; i <= n; i++) { cin >> x >> y; a[i] = x + y + 1, b[i] = x - y + 1001; } cin >> m; for (int i = 1, x, y; i <= m; i++) { cin >> x >> y; c[x + y + 1][x - y + 1001]++; } for (int i = 1; i < MAXV; i++) { for (int j = 1; j < MAXV; j++) { c[i][j] += c[i][j - 1] + c[i - 1][j] - c[i - 1][j - 1]; } } int l = 0, r = MAXV; while (l < r) { int mid = (l + r) >> 1; Check(mid) ? r = mid : l = mid + 1; } cout << l; return 0; }