mod = 1000000007 eps = 10**-9 K = 10 ** 10 def main(): import sys input = sys.stdin.readline def solve(AB, CD, P): N = len(AB) M = len(CD) S = {} for i in range(N): a, b = AB[i] p = P[i] for j in range(M): c, d = CD[j] hsh = (a - c) * K + (b - d) if hsh not in S: S[hsh] = 0 S[hsh] += p res = 0 for s in S: res = max(res, S[s]) return res N, M = map(int, input().split()) P = list(map(int, input().split())) AB = [] CD = [] for _ in range(N): AB.append(tuple(map(int, input().split()))) for _ in range(M): CD.append(tuple(map(int, input().split()))) AB1 = [(-a, b) for a, b in AB] AB2 = [(a, -b) for a, b in AB] AB3 = [(-a, -b) for a, b in AB] ans = max(solve(AB, CD, P), solve(AB1, CD, P), solve(AB2, CD, P), solve(AB3, CD, P)) print(ans) if __name__ == '__main__': main()