To implement the QueueFromStack.