#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), c(M), d(M); map m; set s; long long INF = 2000000000; for(int i = 0; i < N; i++) { cin >> a[i] >> b[i]; a[i] *= 2; b[i] *= 2; m[(a[i] + INF) * INF + b[i]] = i; } for(int i = 0; i < M; i++) { cin >> c[i] >> d[i]; c[i] *= 2; d[i] *= 2; } int ans = 0; for(int i = 0; i < M; i++){ for(int j = 0; j < N; j++){ long long mx = (a[j] + c[i]) / 2; long long my = (b[j] + d[i]) / 2; if(s.count((mx + INF) * INF + my)) continue; s.insert((mx + INF) * INF + my); int res = 0, res2 = 0, res3 = 0, res4 = 0; for(int k = 0; k < M; k++){ long long r = mx * 2 - c[k]; long long l = my * 2 - d[k]; if(m.count((r + INF) * INF + l)) { res += P[m[(r + INF) * INF + l]]; } if(m.count((r + INF) * INF + d[k])){ res2 += P[m[(r + INF) * INF + d[k]]]; } if(m.count((c[k] + INF) * INF + l)){ res3 += P[m[(c[k] + INF) * INF + l]]; } if(m.count((c[k] + INF) * INF + d[k])){ res4 += P[m[(c[k] + INF) * INF + d[k]]]; } } ans = max({ans, res, res2, res3, res4}); } } cout << ans << endl; }