I am facing a peer problem - Artifacts

https://www.codechef.com/problems/ALG09

I couldn’t understand how to solve this problem. Can anyone suggest me the logic to solve this problem. Thank you