two stack method