Click here to read the complete problem statement.
Please anybody give some hint to solve the problem