Var a:array[1..10,1..12] of integer;
n,m,n1,n2,i,j,s1,s2:integer;
b:boolean;
begin
readln(n,m);
for i:=1 to n do
for j:=1 to m do read(a[i,j]);
readln(n1,n2);
s1:=0; s2:=0; b:=true;
for j:=1 to m do
begin
s1:=s1+a[n1,j]; s2:=s2+a[n2,j];
if a[n1,j]<>a[n2,j] then b:=false;
end;
if b then write('YES, s1 = ',s1) else write('NO, s2 = ',s2);
end.
Пример:
3 4
1 2 3 4
2 3 1 4
1 2 3 4
1 3
YES, s1 = 10