N,K=map(int,input().split()) wal=[] for i in range(N): x,y,hp=map(int,input().split()) x,y=x+500,y+500 wal.append((x,y,hp)) imos=[[0]*1510 for _ in range(1510)] for i in range(K): ax,ay,w,h,d=map(int,input().split()) ax,ay=ax+500,ay+500 imos[ax][ay]+=d imos[ax][ay+h+1]-=d imos[ax+w+1][ay]-=d imos[ax+w+1][ay+h+1]+=d for i in range(1500): for j in range(1500): imos[i+1][j]+=imos[i][j] for i in range(1500): for j in range(1500): imos[i][j+1]+=imos[i][j] ans=0 for x,y,hp in wal: if imos[x][y]