Logic to solve SIGNTURE COOKOFF NOV 2019

Question Link : CodeChef: Practical coding for everyone
Can anybody tell me approach they are following to solve this question !! Since editorials are not out yet kindly help out ! Thank you!!

come to common thread