class Imos_2: def __init__(self,W,H): self.width=W self.height=H self.list=[[0]*(W+1) for _ in range(H+1)] def add(self,F,T,C=1): """F=(Fx,Fy), T=(Tx,Ty) に対して, 閉区間 [Fx,Tx] x [Fy,Ty] にCを加算する. """ Fx,Fy=F Tx,Ty=T self.list[Fx][Fy]+=C self.list[Fx][Ty+1]-=C self.list[Tx+1][Fy]-=C self.list[Tx+1][Ty+1]+=C def cumulative_sum(self): Y=[[0]*(self.width+1) for _ in range(self.height+1)] for x in range(self.width+1): S=0 for y in range(self.height+1): S+=self.list[y][x] Y[y][x]=S for y in range(self.height+1): S=0 for x in range(self.width+1): S+=Y[y][x] Y[y][x]=S return Y #================================================== import sys input=sys.stdin.readline H,W,N,M=map(int,input().split()) Data=[] for _ in range(N): d=tuple(map(int,input().split())) Data.append(d) I=Imos_2(W+1,H+1) for _ in range(M): X,Y,B,C=map(int,input().split()) X_min=max(1,X-B); X_max=min(H,X+B) Y_min=max(1,Y-B); Y_max=min(W,Y+B) I.add((X_min,Y_min),(X_max,Y_max),C) J=I.cumulative_sum() for x in range(H+1): for y in range(1,W+1): J[x][y]+=J[x][y-1] J=[list(z) for z in zip(*J)] for y in range(W+1): for x in range(1,H+1): J[y][x]+=J[y][x-1] J=[list(z) for z in zip(*J)] K=0 for T,U,L,R,A in Data: Attack=J[U][R]-J[T-1][R]-J[U][L-1]+J[T-1][L-1] if Attack