CHEFS IN QUEUE (CHFQUEUE) WRONG ANSWER

I have tried to solve this problem CHFQUEUE Problem - CodeChef using stacks as told in the editorial. CHFQUEUE - Editorial
I am getting WA for all test cases and I am unable to find what’s wrong in the code.