program Project14;

{\$APPTYPE CONSOLE}

uses
SysUtils;

type mas=array[1..100,1..100] of integer;
mn=set of 1..100;

Procedure vvod(var a:mas; n,m:integer);
var i,j:integer;
begin
writeln('Vvod matrici:');
for i:=1 to n do
begin
for j:=1 to m do
end;
end;

Procedure vivod(var a:mas; n,m:integer);
var i,j:integer;
begin
for i:=1 to n do
begin
for j:=1 to m do
write(a[i,j],' ');
writeln;
end;
end;

Procedure vvod_mn(var k:mn);
var i,l:integer;
var ki:1..100;
begin
writeln('Kol-vo elementov mnogestva:');
k:=[];
writeln('Mnogestvo:');
for i:=1 to l do
begin
k:=k+[ki];
end;
end;

Function sum(var a:mas; n,m:integer; var k1,k2:mn):integer;
var i,j,s:integer;
var i1,j1:char;
begin
s:=0;
for i:=1 to n do
for j:=1 to m do
if (i in k1) and (j in k2) then s:=s+a[i,j];
sum:=s;
end;

var a1:mas;
var n1,m1,sum1:integer;
var s1,s2:mn;
BEGIN
writeln('Kol-vo strok:');
writeln('Kol-vo stolbcov:');
vvod(a1,n1,m1);
writeln('Ishodnaya matrica:');
vivod(a1,n1,m1);
writeln('Mnogestva s1 i s2:');
vvod_mn(s1);
vvod_mn(s2);
sum1:=sum(a1,n1,m1,s1,s2);
writeln('Summa = ',sum1);