Click here to read the complete problem statement.
How to solve this? Can some give me the answer or hint?