I have attached the screenshot of the problem statement any help in coming up with the solution. http://codeforces.com/predownloaded/dc/3a/dc3a95cd31acc2b686bf505760140774ad84427b.png http://codeforces.com/predownloaded/49/4f/494f83b63edfc3713a93d927c2a7ad4931a0feac.png