CYCLE DETECTION AND REMOVAL PROBLEM : i am getting TLE in some test cases