#include using namespace std; const int N = 2e5 + 10, M = 4e3 + 10, W = 2e3; int n, x[N], y[N], m, z[N], w[N], tr[M][M]; int lowbit(int x) { return x & (-x); } void add(int x, int y) { for (int i = x; i < M; i += lowbit(i)) { for (int j = y; j < M; j += lowbit(j)) { tr[i][j]++; } } } int query(int x, int y) { int ret = 0; for (int i = x; i > 0; i -= lowbit(i)) { for (int j = y; j > 0; j -= lowbit(j)) { ret += tr[i][j]; } } return ret; } int getans(int x1, int y1, int x2, int y2) { x1 = max(x1, 0), x2 = min(x2, M - 1); y1 = max(y1, 0), y2 = min(y2, M - 1); return query(x2, y2) - query(x1 - 1, y2) - query(x2, y1 - 1) + query(x1 - 1, y1 - 1); } bool Check(int d) { for (int i = 0; i < M; i++) { fill(tr[i], tr[i] + M, 0); } for (int i = 1; i <= n; i++) add(x[i], y[i]);//, cout << x[i] << ' ' << y[i] << '\n'; for (int i = 1; i <= m; i++) { int k = getans(z[i] - d, w[i] - d, z[i] + d, w[i] + d); //cout << z[i] - d << ' ' << w[i] - d << ' ' << z[i] + d << ' ' << w[i] + d << '\n'; if (k) return 0; } for (int i = 0; i < M; i++) { fill(tr[i], tr[i] + M, 0); } for (int i = 1; i <= m; i++) add(z[i], w[i]); for (int i = 1; i <= n; i++) { int k = getans(x[i] - d, y[i] - d, x[i] + d, y[i] + d); if (k) return 0; } return 1; } int main() { ios::sync_with_stdio(0), cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i]; int t = y[i]; y[i] = x[i] - y[i], x[i] += t; x[i] += W, y[i] += W; } cin >> m; for (int i = 1; i <= n; i++) { cin >> z[i] >> w[i]; int t = w[i]; w[i] = z[i] - w[i], z[i] += t; z[i] += W, w[i] += W; } int l = 0, r = 2e3; while (l < r) { int mid = (l + r) >> 1; Check(mid) ? l = mid + 1 : r = mid; //cout << l << ' ' << r << '\n'; } cout << l; //cout << Check(1); return 0; }