#include #define _1 (__int128)1 using namespace std; using ll = long long; void FileIO (const string s) { freopen(string(s + ".in").c_str(), "r", stdin); freopen(string(s + ".out").c_str(), "w", stdout); } const int N = 2e5 + 10; int n, x[N], y[N], m, x_[N], y_[N], l, r = 2000, sum[2010][2010]; bool f[2010][2010]; bool check (int dis) { for (int i = 0; i <= 2000; i++) for (int j = 0; j <= 2000; j++) sum[i][j] = 0; for (int i = 1; i <= n; i++) sum[max(0, x[i] - dis)][max(0, y[i] - dis)]++, sum[max(0, x[i] - dis)][min(2000, y[i] + dis) + 1]--, sum[min(2000, x[i] + dis) + 1][max(0, y[i] - dis)]--, sum[min(2000, x[i] + dis) + 1][min(2000, y[i] + dis) + 1]++; for (int i = 0; i <= 2000; i++) for (int j = 1; j <= 2000; j++) sum[i][j] += sum[i][j - 1]; for (int i = 1; i <= 2000; i++) for (int j = 0; j <= 2000; j++) sum[i][j] += sum[i - 1][j]; for (int i = 0; i <= 2000; i++) for (int j = 0; j <= 2000; j++) if (sum[i][j] && f[i][j]) return 1; return 0; } signed main () { ios::sync_with_stdio(0), cin.tie(0); // FileIO(""); cin >> n; for (int i = 1, a, b; i <= n; i++) cin >> a >> b, x[i] = a + b, y[i] = a - b + 1000; cin >> m; for (int i = 1, a, b; i <= m; i++) cin >> a >> b, x_[i] = a + b, y_[i] = a - b + 1000, f[x_[i]][y_[i]] = 1; while (l < r) { int mid = (l + r) >> 1; if (check(mid)) r = mid; else l = mid + 1; } cout << l; return 0; }