CHFIDEAL problem

Unable to understand CHIDEAL testcase . Please help me out with the testcase. getting TLE for both the testcases after submitting.