program queue;
type
fxz=array[0..10] of longint;
var
f1,f2:text;
l,q,i,j,x,n:integer;
a:fxz;
begin
assign(f1,'queue.in');
assign(f2,'queue.out');
reset(f1);rewrite(f2);
readln(f1,n);l:=0;
for i:=1 to n do
begin
read(f1,x);
if x=1 then for j:=1 to l do begin a[j]:=0;l:=0;end;
if x=2 then if l<10 then begin read(f1,q);inc(l);a[l]:=q;end
else writeln(f2,'queue out');
if x=3 then if l>0 then begin dec(l);for j:=1 to l do a[j]:=a[j+1]end
else writeln(f2,'queue empty');
if x=4 then begin writeln(f2,l);for j:=1 to l do write(f2,a[j],' ');end;
readln(f1);
end;
close(f1);close(f2);
end.