GYM Problem
Can someone suggest an appraoch to solve problem F of this link !! http://codeforces.com/gym/100610