测试结果2: 答案错误|Special Judge:答案错误
测试结果3: 通过本测试点|有效耗时46ms
测试结果4: 通过本测试点|有效耗时47ms
测试结果5: 通过本测试点|有效耗时46ms
测试结果6: 通过本测试点|有效耗时47ms
测试结果7: 通过本测试点|有效耗时46ms
测试结果8: 答案错误|Special Judge:选手输出格式错误,或数字数目与标准输出不符。
测试结果9: 答案错误|Special Judge:答案错误
测试结果10: 答案错误|Special Judge:答案错误
var n,i,j,x,y,top,tail,k:integer;
d:array[1..10,1..10]of integer;
v,res,t:array[1..10]of integer; //t 标记 res结果 v入度
begin
readln(n);
fillchar(d,sizeof(d),0); fillchar(v,sizeof(v),0);
fillchar(res,sizeof(res),0); fillchar(t,sizeof(t),0);
for i:=1 to n do
begin
read(x);
for j:=1 to x do
begin
read(y); d[y,i]:=1; inc(v[i]);
end;
end;
for i:=1 to n do
if v[i]=0 then begin res[1]:=i; k:=i; t[i]:=1; break; end; j:=2;
top:=1; tail:=1;
while top<=tail do
begin
for i:=1 to n do
if (d[k,i]=1) and (t[i]=0) then
begin
inc(tail);
if v[i]<>0 then dec(v[i]);
if (v[i]=0) then begin res[j]:=i; inc(j); k:=i; t[i]:=1; end;
end;
inc(top);
end;
for i:=1 to n do
begin
if res[i]=1 then begin k:=i; write(res[1]); for j:=2 to k do write(' ',res[j]); halt; end;
end;
writeln('What a poor boy!');
end.