http://www.codechef.com/FEB14/problems/LCPESY