from collections import defaultdict N,M=map(int,input().split()) P=list(map(int,input().split())) S=[] for _ in range(N): a,b=map(int,input().split()) S.append((a,b)) T=[] for j in range(M): c,d=map(int,input().split()) T.append((c,d)) X=0 for s,t in [(1,1),(1,-1),(-1,1),(-1,-1)]: D=defaultdict(int) for i in range(N): a,b=S[i] for j in range(M): c,d=T[j] p=c-s*a; q=d-t*b D[(p<<32)^q]+=P[i] X=max(X,max(D.values())) print(X)