http://www.codechef.com/COOK34/problems/AMSGAME1