http://www.spoj.com/problems/ATOMS/