http://www.codechef.com/APRIL13/problems/KINGCON