#include using namespace std; int main(){ int N, M; cin >> N >> M; vector P(N); for (int i = 0; i < N; i++){ cin >> P[i]; } vector a(N), b(N); for (int i = 0; i < N; i++){ cin >> a[i] >> b[i]; } vector c(M), d(M); for (int i = 0; i < M; i++){ cin >> c[i] >> d[i]; } int ans = 0; for (int i = 0; i < 2; i++){ for (int j = 0; j < 2; j++){ map> mp; for (int k = 0; k < M; k++){ for (int l = 0; l < N; l++){ int x; if (i == 0){ x = a[l] - c[k]; } else { x = a[l] + c[k]; } int y; if (j == 0){ y = b[l] - d[k]; } else { y = b[l] + d[k]; } mp[x][y] += P[l]; } } for (auto x : mp){ for (auto y : x.second){ ans = max(ans, y.second); } } } } cout << ans << endl; }