solve the AUTOPRODUCTION poblem 'http://algospot.com/judge/problem/read/AUTOPRODUCTION'