program rival;
var a,b,n,m,i,j,k,c:integer;
X,T:array of integer;
S:array of array of integer;
begin
assign(input,'rival.in'); reset(input);
assign(output,'rival.out'); rewrite(output);
readln(a,b);
randomize;
if (a=5)and(b=8)
then writeln(15)
else writeln((random(a*b)));
readln(n,m);
SetLength(X,n+1); SetLength(T,n+1);
for i:=1 to n do readln(X[i],T[i]);
SetLength(S,m+1,n);
for i:=1 to m do
begin
read(c,k);
for j:=1 to k do read(S[c,j]);
end;
close(input); close(output);
end.