• + 1 comment

    perl:

    while(<>){($c,$v)=split;$c==1?push@q,$v:$c==2?shift@q:$c==3&&print"$q[0]\n"}