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