$e[@e]=<>for 1..<>;map{for$b($_!~('(\S+) 'x4),$4+1){$m{$1+$_,$2+$b}+=!$_^!$b?-$':$' for$3+1,0}}<>;for$y(@i=-500..500){$s=0;$$_{$y}+=$$_{$y-1}+($s=$m{$_,$y}+=$s)for@i;}($x,$y,$h)=split,$\+=$-=$h-$$x{$y}for@e;print