Chef and Secret Recipe (Lunchtime March)

Can anyone tell me how to solve this problem . I tried but not able to solve it .
Link - https://www.codechef.com/LTIME82A/problems/SCRRCP