program queue;
var que:array[0..10]of integer;
n,i,j,a,b,long:integer;
f1,f2:text;
begin
assign(f1,'queue.in');
reset(f1);
assign(f2,'queue.out');
rewrite(f2);
readln(f1,n);
for j:=1 to n do
begin
read(f1,a);
case a of
1:begin
for i:=1 to long do
que[i]:=0;
long:=0;
end;
2:if long<10 then
begin
read(f1,que[long+1]);
long:=long+1;
end else writeln(f2,'queue out');
3:if long>0 then
begin
que[1]:=0;
for i:=1 to long-1 do
que[i]:=que[i+1];
long:=long-1;
end else writeln(f2,'queue empty');
4:begin
writeln(f2,long);
for i:=1 to long do
write(f2,que[i],' ');
end;
end;
end;
close(f1);
close(f2);
end.