Pagini recente » Cod sursa (job #3133743) | Cod sursa (job #2457181) | Cod sursa (job #788586) | Cod sursa (job #1443225) | Cod sursa (job #27845)
Cod sursa(job #27845)
var min,max,a,b: array[1..1024] of byte;
n,m,k,i,j,c,rez: integer;
begin
assign(input,'balanta.in'); reset(input);
fillchar(min,sizeof(min),0);
fillchar(max,sizeof(max),0);
read(n,m);
for c:=1 to m do
begin
read(k);
fillchar(a,sizeof(a),0);
for i:=1 to k do
begin read(j); a[j]:=1; end;
fillchar(b,sizeof(b),0);
for i:=1 to k do
begin read(j); b[j]:=1; end;
read(rez);
if rez=0 then
for i:=1 to n do
if a[i]+b[i]>0 then
begin
min[i]:=1;
max[i]:=1;
end;
if rez=1 then
for i:=1 to n do
begin
if a[i]=0 then max[i]:=1;
if b[i]=0 then min[i]:=1;
end;
if rez=2 then
for i:=1 to n do
begin
if b[i]=0 then max[i]:=1;
if a[i]=0 then min[i]:=1;
end;
end;
i:=0;
for c:=1 to n do
if min[c]=0 then begin i:=i+1; k:=c; end;
j:=0;
for c:=1 to n do
if max[c]=0 then begin j:=j+1; k:=c; end;
assign(output,'balanta.out'); rewrite(output);
if i+j=1 then writeln(k)
else writeln(0);
close(output);
end.