Program queue;
Type
sc=array [1..10] of integer;
Var
s:sc;
l,n,i,j:integer;
o,oo:integer;
f1,f2:text;
Begin
assign(f1,'queue.in');
assign(f2,'queue.out');
reset(f1);
rewrite(f2);
for i:=1 to 10 do s[i]:=0;
readln(f1,n);
for i:=1 to n do begin
read(f1,o);
if o=2 then readln(f1,oo)
else readln(f1);
case o of
1:begin
for j:=1 to 10 do s[j]:=0;
l:=0;
end;
2:begin
if l<10 then begin
s[l+1]:=oo;
l:=l+1;
end
else writeln(f2,'queue out');
end;
3:begin
if l<>0 then begin
s[1]:=0;
for j:=2 to l do
s[j-1]:=s[j];
l:=l-1;
end
else writeln(f2,'queue empty');
end;
4:begin
writeln(f2,l);
for j:=1 to l do write(f2,s[j],' ');
writeln(f2);
end;
end;
end;
close(f1);
close(f2);
End.