#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);}) #define rd_skip_line() while(*rp++!=10) #define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) #define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);}) #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);}) #define rep(v,e) for(typeof(e) v=0;v=b?a:b) typedef unsigned long ulong; long f[2002][2002]; void f1(char*rp,long h,long w,long n){ rep(i,n)rd_skip_line(); while(*rp){ long x=rd(); long y=rd(); long b=rd(); long c=rd(); long x0=max(0,x-b); long x1=min(h,x+b)+1; long y0=max(0,y-b); long y1=min(w,y+b)+1; f[x0][y0]+=c; f[x0][y1]-=c; f[x1][y0]-=c; f[x1][y1]+=c; } } void f2(long h,long w){ rep(x,h+1){ long d=0,e=0; rep(y,w+1){ f[x][y]=d+=e+=f[x][y]; } } rep(y,w+1){ long d=0,e=0; rep(x,h+1){ f[x][y]=d+=e+=f[x][y]; } } } long f3(char*rp,long n){ long z=0; rep(i,n){ long t=rd()-1; long u=rd(); long l=rd()-1; long r=rd(); long a=rd(); z+=a>f[t][l]-f[t][r]-f[u][l]+f[u][r]; } return z; } int main(){ rd_init(); long h=rd(); long w=rd(); long n=rd(); rd_skip_line(); f1(rp,h,w,n); f2(h,w); wt1(f3(rp,n)); _exit(0); }