How to Calculate FIFO and LIFO