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)] 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=(fx,fy,bx-cx*fx,by-cy*fy) if v not in d: d[v]=0 d[v]+=p[i] print(max(d[v] for v in d))