http://www.codechef.com/MAY13/problems/WITMATH