{*******************************************}
{* Program Name:queue *}
{* Input file:queue.in *}
{* Output file:queue.out *}
{* Date:2008.7.22 *}
{* Programmer:Peng Bo *}
{*******************************************}
program queue;
type
dl=array[1..10]of longint;
var
i,o:text;
s:dl;
n:word;
l:byte;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure dl2;
var
t:longint;
begin
readln(i,t);
if l<11
then
begin
s[l]:=t;
inc(l);
end
else
writeln(o,'queue out');
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure dl3;
var
j:byte;
begin
if l>1
then
begin
if l>2
then
for j:=1 to l-2 do
s[j]:=s[j+1];
dec(l);
end
else
writeln(o,'queue empty');
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure dl4;
var
j:byte;
begin
writeln(o,l-1);
for j:=1 to l-1 do
write(o,s[j],' ');
writeln(o);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure fileb;
begin
assign(i,'queue.in');
reset(i);
readln(i,n);
assign(o,'queue.out');
rewrite(o);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure filef;
begin
close(i);
close(o);
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure main;
var
j:word;
f:byte;
begin
for j:=1 to n do
begin
read(i,f);
case f of
1:l:=1;
2:dl2;
3:dl3;
4:dl4;
end;
end;
end;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
l:=1;
fileb;
main;
filef;
end.
{End.}