n,m=map(int,input().split()) p=list(map(int,input().split())) c=[tuple(map(int,input().split())) for i in range(n)] b=[tuple(map(int,input().split())) for i in range(m)] L=9 d={} for fx in [1,-1]: for fy in [1,-1]: for i in range(n): for j in range(m): cx,cy=c[i] bx,by=b[j] v=0 v+=(fx+1)*2+(fy+1) v*=10 v+=(bx-cx*fx)+10**L v*=10**(L+1) v+=(by-cy*fy)+10**L if v not in d: d[v]=0 d[v]+=p[i] print(max([d[v] for v in d]+[0]))