Logic to solve SIGNTURE COOKOFF NOV 2019

Question Link : https://www.codechef.com/COOK112B/problems/SIGNTURE
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