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