LIFO and FIFO simulation