https://www.spoj.com/problems/AGGRCOW/