program cch(input,output,f1,f2);
var
f1,f2:text;
head,tail,q,i,n:integer;
x:longint;
a:array[1..10] of longint;
procedure empty;
begin
head:=0; tail:=0;
end;
procedure inqueue(x:longint);
begin
if tail=10 then writeln(f2,'queue out')
else begin
if head=0 then head:=1;
inc(tail);
a[tail]:=x;
end;
end;
procedure outqueue;
begin
if head=0 then writeln(f2,'queue empty')
else inc(head);
end;
procedure print;
var
i:integer;
begin
if head=0 then exit;
writeln(f2,tail-head+1);
for i:=head to tail-1 do write(f2,a[i],' ');
writeln(f2,a[tail]);
end;
begin
assign(f1,'queue.in');
assign(f2,'queue.out');
reset(f1);
rewrite(f2);
readln(f1,n);
for i:=1 to n do begin
read(f1,q);
case q of
1:empty;
2:begin readln(f1,x);
inqueue(x);
end;
3:outqueue;
4:print;
end;
end;
close(f1);
close(f2);
end.