The last mssg was on problem 1168 :) (+)
Anyway...
type
point = record
i, j: integer;
end;
var
p: array[1..1000] of point;
s: array[1..1000] of real;
a: array[1..50,1..50] of longint;
used: array[1..50,1..50] of boolean;
ans, M, N, K: integer;
function dis(x,y:point): real;
var
ii,jj,hh:real;
begin
ii := (x.i-y.i)*(x.i-y.i);
jj := (x.j-y.j)*(x.j-y.j);
hh := (a[x.i,x.j]-a[y.i,y.j])*(a[x.i,x.j]-a[y.i,y.j]);
dis:=sqrt(ii+jj+hh);
end;
var
where:point;
i, j, l:integer;
label bad;
begin
readln(M,N,K);
for i:=1 to M do
for j:=1 to N do used[i,j]:=false;
for i:=1 to M do begin
for j:=1 to N do read(a[i,j]);
readln;
end;
for l:=1 to K do
readln(p[l].i,p[l].j,s[l]);
for l:=1 to K do
used[p[l].i,p[l].j]:=true;
ans:=0;
for i:=1 to M do
for j:=1 to N do
if not used[i,j] then begin
where.i:=i; where.j:=j;
while a[i,j]<=32000 do begin
for l:=1 to K do
if dis(where,p[l])>s[l] then goto bad;
inc(a[i,j]);
inc(ans);
end;
bad:
end;
write(ans);
end.