Pagini recente » Cod sursa (job #2399451) | Cod sursa (job #1228463) | Cod sursa (job #2127640) | Cod sursa (job #871262) | Cod sursa (job #49310)
Cod sursa(job #49310)
type vector= set of 1..1024;
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=0) and (cardl=0)
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.