Logic for Queue with two stacks