Pagini recente » Cod sursa (job #720803) | Cod sursa (job #2355780) | Cod sursa (job #3129078) | Cod sursa (job #3192493) | Cod sursa (job #49321)
Cod sursa(job #49321)
type vector= set of 1..255;
var a,b,h,l:vector;
f,g:text;
n,m,i,j,k,z,cardh,cardl:0..1024;
r:0..2;
begin
assign(f,'balanta.in'); assign(g,'balanta.out');
reset(f); rewrite(g);
readln(f,n,m);
for i:=1 to n do
begin
h:=h+[i];
l:=l+[i];
end;
for i:=1 to m do
begin
a:=[]; b:=[];
read(f,k);
for j:=1to k do
begin
read(f,z);
a:=a+[z];
end;
for j:=1 to k do
begin
read(f,z);
b:=b+[z];
end;
readln(f,r);
if r=0 then begin h:=h-a-b;l:=l-a-b; end
else
if r=1 then begin h:=h*a; l:=l*b; end
else begin h:=h*b; l:=l*a; end;
end;
cardh:=0; cardl:=0;
for i:=1 to n do
begin
if i in h then inc(cardh);
if i in l then inc(cardl);
end;
if (cardh=cardl)
then write(g,0)
else
if cardl=1
then begin for i:=1 to n do if i in l then write(g,i); end
else
for i:=1 to n do if i in h then write(g,i);
close(f);close(g);
end.