http://www.codechef.com/COOK46/problems/ANUDTC