https://www.codechef.com/ECPG2020/problems/ECPC10F
Editorial for this problem will be released by today night.
thanks