Puzzle Hunt Codechef Solution